Date - Time Format
am 20.08.2005 04:58:47 von Doug
I am using ASP to access a database and pull out the date in the database
that is in this format: 7/5/2005 9:20:22 AM
I want to make it display on the page in this format which is a standard
miltary DTG(Date/Time/Group) format and in Zulu (GMT - Grenwich Mean Time).
For example this would be how I would display the above date and time:
050920Z JUL 05
DDHHMMZ MMM CC
Any clue as to how to get this done?
I did find this webpage, but copied and pasted over to an asp page on the
server, and I get an error...the page is from 2003, so maybe the code has
changed a bit?
http://www.frontpagewebmaster.com/m-127132/tm.htm#127132
Any help is appreciated.
Thanks,
Doug
Re: Date - Time Format
am 20.08.2005 07:28:09 von McKirahan
"Doug" wrote in message
news:I%wNe.761$UI.20@okepread05...
> I am using ASP to access a database and pull out the date in the database
> that is in this format: 7/5/2005 9:20:22 AM
>
> I want to make it display on the page in this format which is a standard
> miltary DTG(Date/Time/Group) format and in Zulu (GMT - Grenwich Mean
Time).
> For example this would be how I would display the above date and time:
>
> 050920Z JUL 05
>
> DDHHMMZ MMM CC
>
> Any clue as to how to get this done?
>
> I did find this webpage, but copied and pasted over to an asp page on the
> server, and I get an error...the page is from 2003, so maybe the code has
> changed a bit?
>
> http://www.frontpagewebmaster.com/m-127132/tm.htm#127132
>
> Any help is appreciated.
>
> Thanks,
>
> Doug
Will this help? Watch for word-wrap.
WScript.Echo DateTimeGroup(Now)
Function DateTimeGroup(strNOW)
'****
'* 7/5/2005 9:20:22 AM = 050920Z JUL 05 = DDHHMMZ MMM CC
'****
Const cGMT = 5 '= GMT Offset Hours
Const cMOS = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"
strNOW = DateAdd("h",cGMT,strNOW)
Dim strDTG
strDTG = Right(100+DatePart("d",strNOW),2)
strDTG = strDTG & Right(100+DatePart("h",strNOW),2)
strDTG = strDTG & Right(100+DatePart("n",strNOW),2) & "Z "
strDTG = strDTG & Mid(cMOS,DatePart("m",strNOW)*3-2,3) & " "
strDTG = strDTG & Right(DatePart("yyyy",strNOW),2)
DateTimeGroup = strDTG
End Function
Re: Date - Time Format
am 20.08.2005 15:45:26 von reb01501
Doug wrote:
> I am using ASP to access a database
What database? Type and version please ...
> and pull out the date in the
> database that is in this format: 7/5/2005 9:20:22 AM
Actually, the data is probably not stored in this format. The details about
how it is actually stored depend on the database you are using, but I feel
confident in saying that if you are using a true date/time datatype, the
date will not be stored with any format.
>
> I want to make it display on the page in this format which is a
> standard miltary DTG(Date/Time/Group) format and in Zulu (GMT -
> Grenwich Mean Time). For example this would be how I would display
> the above date and time:
>
> 050920Z JUL 05
>
> DDHHMMZ MMM CC
>
> Any clue as to how to get this done?
McKirahan showed how to do it with vbscript. If you'd rather do it in your
SQL query, let us know what database you are using.
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Re: Date - Time Format
am 02.09.2005 03:15:38 von Doug
I am using MS Access.
Thanks,
Doug
"Bob Barrows [MVP]" wrote in message
news:OBDQk1YpFHA.3316@TK2MSFTNGP14.phx.gbl...
> Doug wrote:
> > I am using ASP to access a database
>
> What database? Type and version please ...
>
> > and pull out the date in the
> > database that is in this format: 7/5/2005 9:20:22 AM
>
> Actually, the data is probably not stored in this format. The details
about
> how it is actually stored depend on the database you are using, but I feel
> confident in saying that if you are using a true date/time datatype, the
> date will not be stored with any format.
>
> >
> > I want to make it display on the page in this format which is a
> > standard miltary DTG(Date/Time/Group) format and in Zulu (GMT -
> > Grenwich Mean Time). For example this would be how I would display
> > the above date and time:
> >
> > 050920Z JUL 05
> >
> > DDHHMMZ MMM CC
> >
> > Any clue as to how to get this done?
>
> McKirahan showed how to do it with vbscript. If you'd rather do it in your
> SQL query, let us know what database you are using.
>
> Bob Barrows
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>
>
Re: Date - Time Format
am 02.09.2005 03:24:10 von reb01501
Doug wrote:
> I am using MS Access.
>
Why don't you tell us the version? That's important too.
I'm assuming that since you replied, you must have a further question? Could
you let us know what it is?
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Re: Date - Time Format
am 02.09.2005 03:41:38 von Doug
I may rather do it in SQL Query, but at this point I'm not sure. Thanks for
the help and sorry for not specifying the version. It is MS Access 2002.
Thanks,
Doug
"Bob Barrows [MVP]" wrote in message
news:%23yZxA01rFHA.3424@TK2MSFTNGP14.phx.gbl...
> Doug wrote:
> > I am using MS Access.
> >
>
> Why don't you tell us the version? That's important too.
>
> I'm assuming that since you replied, you must have a further question?
Could
> you let us know what it is?
>
> Bob Barrows
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>
>
Re: Date - Time Format
am 02.09.2005 04:21:23 von reb01501
Now what you have to realize is that you can use VBA functions in your
queries. And that many of the functions found in vbscript (especially the
date and string functions) are also found in VBA.The most useful function is
Format() which I advise you to get to know and love. This function makes
your task relatively easy:
sql="select ucase(format([DateField],""ddhhmmZ MMMyy"")) from table"
set rs=conn.execute(sql,,1)
response.write rs.getstring(,,,"
")
rs.close:set rs=nothing
conn.Close:set conn=nothing
HTH,
Bob Barrows
Doug wrote:
> I may rather do it in SQL Query, but at this point I'm not sure.
> Thanks for the help and sorry for not specifying the version. It is
> MS Access 2002.
>
> Thanks,
>
> Doug
>
> "Bob Barrows [MVP]" wrote in message
> news:%23yZxA01rFHA.3424@TK2MSFTNGP14.phx.gbl...
>> Doug wrote:
>>> I am using MS Access.
>>>
>>
>> Why don't you tell us the version? That's important too.
>>
>> I'm assuming that since you replied, you must have a further
>> question? Could you let us know what it is?
>>
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Re: Date - Time Format
am 03.09.2005 04:46:39 von Doug
Yes! That appears to work. The only problem now is when the database has a
blank field I get an error...I'll work on that myself I hope!
Thanks for the help!
Doug
"McKirahan" wrote in message
news:zNWdnQfxirUDIpveRVn-uA@comcast.com...
> "Doug" wrote in message
> news:I%wNe.761$UI.20@okepread05...
> > I am using ASP to access a database and pull out the date in the
database
> > that is in this format: 7/5/2005 9:20:22 AM
> >
> > I want to make it display on the page in this format which is a
standard
> > miltary DTG(Date/Time/Group) format and in Zulu (GMT - Grenwich Mean
> Time).
> > For example this would be how I would display the above date and time:
> >
> > 050920Z JUL 05
> >
> > DDHHMMZ MMM CC
> >
> > Any clue as to how to get this done?
> >
> > I did find this webpage, but copied and pasted over to an asp page on
the
> > server, and I get an error...the page is from 2003, so maybe the code
has
> > changed a bit?
> >
> > http://www.frontpagewebmaster.com/m-127132/tm.htm#127132
> >
> > Any help is appreciated.
> >
> > Thanks,
> >
> > Doug
>
>
> Will this help? Watch for word-wrap.
>
>
> WScript.Echo DateTimeGroup(Now)
>
> Function DateTimeGroup(strNOW)
> '****
> '* 7/5/2005 9:20:22 AM = 050920Z JUL 05 = DDHHMMZ MMM CC
> '****
> Const cGMT = 5 '= GMT Offset Hours
> Const cMOS = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC"
> strNOW = DateAdd("h",cGMT,strNOW)
> Dim strDTG
> strDTG = Right(100+DatePart("d",strNOW),2)
> strDTG = strDTG & Right(100+DatePart("h",strNOW),2)
> strDTG = strDTG & Right(100+DatePart("n",strNOW),2) & "Z "
> strDTG = strDTG & Mid(cMOS,DatePart("m",strNOW)*3-2,3) & " "
> strDTG = strDTG & Right(DatePart("yyyy",strNOW),2)
> DateTimeGroup = strDTG
> End Function
>
>
Re: Date - Time Format
am 03.09.2005 05:03:53 von Doug
Bob,
I have tried your code in my SQL statement. I have double checked the
syntax etc.. and can't seem to figure out what is wrong... I get this error
in my browser. Microsoft][ODBC Microsoft Access Driver] Too few parameters.
Expected 1.
I replaced DateField with my table data (ie. tblEvents.EndTime). Maybe that
has something to do with it.
Thanks,
Doug
"Bob Barrows [MVP]" wrote in message
news:%23Xw8%23T2rFHA.3796@TK2MSFTNGP11.phx.gbl...
> Now what you have to realize is that you can use VBA functions in your
> queries. And that many of the functions found in vbscript (especially the
> date and string functions) are also found in VBA.The most useful function
is
> Format() which I advise you to get to know and love. This function makes
> your task relatively easy:
>
> sql="select ucase(format([DateField],""ddhhmmZ MMMyy"")) from table"
> set rs=conn.execute(sql,,1)
> response.write rs.getstring(,,,"
")
>
> rs.close:set rs=nothing
> conn.Close:set conn=nothing
>
> HTH,
> Bob Barrows
>
> Doug wrote:
> > I may rather do it in SQL Query, but at this point I'm not sure.
> > Thanks for the help and sorry for not specifying the version. It is
> > MS Access 2002.
> >
> > Thanks,
> >
> > Doug
> >
> > "Bob Barrows [MVP]" wrote in message
> > news:%23yZxA01rFHA.3424@TK2MSFTNGP14.phx.gbl...
> >> Doug wrote:
> >>> I am using MS Access.
> >>>
> >>
> >> Why don't you tell us the version? That's important too.
> >>
> >> I'm assuming that since you replied, you must have a further
> >> question? Could you let us know what it is?
> >>
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>
>
Re: Date - Time Format
am 03.09.2005 13:24:26 von reb01501
This usually means that you are using a reserved keyword in your statement.
See here for a list of reserved words:
http://www.aspfaq.com/show.asp?id=2080
Best practice is to avoid using these words for your database objects (table
and field names). If you can't rename the problem objects for some reason,
you will need to remember to enclose the problem names with brackets [] when
using them in your queries run via ADO.
If that is not the problem, then you will need to show us the entire sql
statement. Try cutting everything out of it except the part that causes the
problem and show us the result of
Response.Write sqlstatement
where sqlstatement represents the variable containing your sql statement.
Also, you should stop using the ODBC driver and switch to the native Jet
provider instead. See:
http://www.aspfaq.com/show.asp?id=2126
Doug wrote:
> Bob,
>
> I have tried your code in my SQL statement. I have double checked the
> syntax etc.. and can't seem to figure out what is wrong... I get this
> error in my browser. Microsoft][ODBC Microsoft Access Driver] Too
> few parameters. Expected 1.
>
> I replaced DateField with my table data (ie. tblEvents.EndTime).
> Maybe that has something to do with it.
>
> Thanks,
>
> Doug
>
> "Bob Barrows [MVP]" wrote in message
> news:%23Xw8%23T2rFHA.3796@TK2MSFTNGP11.phx.gbl...
>> Now what you have to realize is that you can use VBA functions in
>> your queries. And that many of the functions found in vbscript
>> (especially the date and string functions) are also found in VBA.The
>> most useful function is Format() which I advise you to get to know
>> and love. This function makes your task relatively easy:
>>
>> sql="select ucase(format([DateField],""ddhhmmZ MMMyy"")) from table"
>> set rs=conn.execute(sql,,1)
>> response.write rs.getstring(,,,"
")
>>
>> rs.close:set rs=nothing
>> conn.Close:set conn=nothing
>>
>> HTH,
>> Bob Barrows
>>
>> Doug wrote:
>>> I may rather do it in SQL Query, but at this point I'm not sure.
>>> Thanks for the help and sorry for not specifying the version. It is
>>> MS Access 2002.
>>>
>>> Thanks,
>>>
>>> Doug
>>>
>>> "Bob Barrows [MVP]" wrote in message
>>> news:%23yZxA01rFHA.3424@TK2MSFTNGP14.phx.gbl...
>>>> Doug wrote:
>>>>> I am using MS Access.
>>>>>
>>>>
>>>> Why don't you tell us the version? That's important too.
>>>>
>>>> I'm assuming that since you replied, you must have a further
>>>> question? Could you let us know what it is?
>>>>
>>
>> --
>> Microsoft MVP - ASP/ASP.NET
>> Please reply to the newsgroup. This email account is my spam trap so
>> I don't check it very often. If you must reply off-line, then remove
>> the "NO SPAM"
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"