Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Formatting datetime


Message #1 by jonathan frascella <jonathan.frascella@N...> on Wed, 30 Aug 2000 09:45:16 +0100
This message is in MIME format. Since your mail reader does not understand

this format, some or all of this message may not be legible.



------_=_NextPart_001_01C0125E.9EC6766A

Content-Type: text/plain;

	charset="iso-8859-1"



I am trying to display the date and time that a user posts a message to a

message board, but it keeps returning hundredths of a second too.

 

Without changing the SQL database fields (datetime, length = 8), is there a

way to output the fields with formatting?

 

Jonathan




Message #2 by Imar Spaanjaars <Imar@S...> on Wed, 30 Aug 2000 14:59:21 +0200
Funny, your message subject is almost the solution as well ;-)



Try FormatDateTime(Date[, NamedFormat]) in VB script, where NamedFormat] 

can be:



vbGeneralDate   0       Display a date and/or time. If there is a date 

part, display it as a short date. If there is a time

                                 part, display it as a long time. If 

present, both parts are displayed.

vbLongDate              1       Display a date using the long date format 

specified in your computer's regional settings.

vbShortDate             2       Display a date using the short date format 

specified in your computer's regional settings.

vbLongTime              3       Display a time using the time format 

specified in your computer's regional settings.

vbShortTime             4       Display a time using the 24-hour format 

(hh:mm).





Imar













At 09:45 AM 8/30/2000 +0100, you wrote:

>I am trying to display the date and time that a user posts a message to a 

>message board, but it keeps returning hundredths of a second too.

>

>Without changing the SQL database fields (datetime, length = 8), is there 

>a way to output the fields with formatting?

>

>Jonathan





Message #3 by stephenb@w... on Wed, 30 Aug 2000 15:12:00 +0100
It is often forgotten that different countries use different date formats.

That is, 07/08/99 could equally well be 8th July 1999, 7th August 1899 and

so on. Setting the servers regional locale is no help here, this only

applies to wherever the server happens to live. Similarly there is no

guarantee that the client machine is set correctly. For complete

flexibility and reliability, display all dates in long format

(dd-MMM-yyyy), writing out the month name. When asking for input, get data

for day, month and year separately and concatenate these into a date field

on the server. Offering a list box for each works well.



Remember that what is stored in the database is just a number which has to

conform to certain criteria. Some databases have their own (undocumented!)

assumptions about dates, so make sure that the date string is read and

written consistently (some suggest forcing yyyy/mm/dd format). This is an

entirely separate issue from how you display or receive the date.



Stephen


  Return to Index