now() date format problem between NT and Windows 2000 
Author Message
 now() date format problem between NT and Windows 2000

I'm trying to migrate my Web Site from a NT Server to a
Windows 2000 Server.

On the server side ASP Script when using the built in VB
Script function of NOW() to obtain the current date

under the NT Server NOW() returns the date in the format
MM/DD/YY
under the 2000 Server NOW() returns the date in the format
of MM/DD/YYYY

I have thousands of pages that us this function as part of
SQL queries to my databases in which the SQL is expecting
the format of MM/DD/YY and I'm looking for a way to force
the 2000 Server to bring the date back in the format of
MM/DD/YY without having to go and change all my pages.



Wed, 30 Nov 2005 02:07:47 GMT  
 now() date format problem between NT and Windows 2000
Actually Now() only returns a number (the same in NT and Windows 2000) in a
date-type variable.

When you use a date variable you will typically at some point convert it to
a string and this is where you need to be in control of the conversion.

A simple example is when you write a date variable to the screen like:

WScript.Echo Now()

The way the date is presented depends on your current language setting
(Regionale Options) - in other words the program does not have control of
the conversion.

To ensure that the regional setting doesn't affect your date conversion you
can construct the representation of the date yourself like:

' Get a snapshot of the current time
CurrentDate = Now()
' Construct a US formatted representation of the date
US_DateString = Month(CurrentDate) & "/" & Day(CurrentDate) & "/" &
Right(CStr(Year(CurrentDate)), 2)

If you are going to interface to SQL language you may want to construct
dates and times in a ISO representation to remove any doubt on the
interpretation.

Best regards
Johnny Nielsen



Quote:
> I'm trying to migrate my Web Site from a NT Server to a
> Windows 2000 Server.

> On the server side ASP Script when using the built in VB
> Script function of NOW() to obtain the current date

> under the NT Server NOW() returns the date in the format
> MM/DD/YY
> under the 2000 Server NOW() returns the date in the format
> of MM/DD/YYYY

> I have thousands of pages that us this function as part of
> SQL queries to my databases in which the SQL is expecting
> the format of MM/DD/YY and I'm looking for a way to force
> the 2000 Server to bring the date back in the format of
> MM/DD/YY without having to go and change all my pages.



Wed, 30 Nov 2005 05:24:18 GMT  
 now() date format problem between NT and Windows 2000
... or set up the regional settings in the 2000 server the same as the old
NT server.

Don W.


Quote:
> Actually Now() only returns a number (the same in NT and Windows 2000) in
a
> date-type variable.

> When you use a date variable you will typically at some point convert it
to
> a string and this is where you need to be in control of the conversion.

> A simple example is when you write a date variable to the screen like:

> WScript.Echo Now()

> The way the date is presented depends on your current language setting
> (Regionale Options) - in other words the program does not have control of
> the conversion.

> To ensure that the regional setting doesn't affect your date conversion
you
> can construct the representation of the date yourself like:

> ' Get a snapshot of the current time
> CurrentDate = Now()
> ' Construct a US formatted representation of the date
> US_DateString = Month(CurrentDate) & "/" & Day(CurrentDate) & "/" &
> Right(CStr(Year(CurrentDate)), 2)

> If you are going to interface to SQL language you may want to construct
> dates and times in a ISO representation to remove any doubt on the
> interpretation.

> Best regards
> Johnny Nielsen



> > I'm trying to migrate my Web Site from a NT Server to a
> > Windows 2000 Server.

> > On the server side ASP Script when using the built in VB
> > Script function of NOW() to obtain the current date

> > under the NT Server NOW() returns the date in the format
> > MM/DD/YY
> > under the 2000 Server NOW() returns the date in the format
> > of MM/DD/YYYY

> > I have thousands of pages that us this function as part of
> > SQL queries to my databases in which the SQL is expecting
> > the format of MM/DD/YY and I'm looking for a way to force
> > the 2000 Server to bring the date back in the format of
> > MM/DD/YY without having to go and change all my pages.



Wed, 30 Nov 2005 05:50:26 GMT  
 now() date format problem between NT and Windows 2000
Hi,

There's an almost identical thread in the group below.  In case you missed
it, Michael Harris (MVP) provided the following references:

INFO: Behavior of Date/Time Format Differs When Accessed from Active Server
Pages (Q306044)
http://support.microsoft.com/default.aspx?kbid=306044

VBScript Date and Time Functions May not be Formatted Properly
http://support.microsoft.com/default.aspx?kbid=264063

PRB: VBScript Date and Time Formats Change with Logged on User (Q218964)
http://support.microsoft.com/default.aspx?kbid=218964

Regards,
Joe Earnest



| I'm trying to migrate my Web Site from a NT Server to a
| Windows 2000 Server.
|
| On the server side ASP Script when using the built in VB
| Script function of NOW() to obtain the current date
|
| under the NT Server NOW() returns the date in the format
| MM/DD/YY
| under the 2000 Server NOW() returns the date in the format
| of MM/DD/YYYY
|
| I have thousands of pages that us this function as part of
| SQL queries to my databases in which the SQL is expecting
| the format of MM/DD/YY and I'm looking for a way to force
| the 2000 Server to bring the date back in the format of
| MM/DD/YY without having to go and change all my pages.



Wed, 30 Nov 2005 20:33:47 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. writing vbscript to know the OS of a remote PC ( is WIndows NT or WIndows 2000)

2. Windows 2000 and windows NT in one machine

3. installing vb program in Windows NT, Windows 2000

4. rds windows nt vs windows 2000 server

5. Packaging Apps on Windows 2000 to run on Windows NT

6. Date format problem with NT 4.0

7. Windows 2000/NT Event log monitoring

8. NEW Windows 2000 Professional NT 5.0 PAY BY VISA, M/C, AMEX or DISCOVER

9. Installing PPD for Windows 98, NT, 2000

10. Windows 2000/NT Event log monitoring

11. How to Retrieve Events For One Day From An Event Log on Windows 2000/NT

12. Logging on to an NT Domain in Windows 2000

 

 
Powered by phpBB® Forum Software