SQL Server 2000 not accepting UK format dates.
#1
I have a field set as datetime and when I try to input a date in UK fomat
(eg 26/07/2002) it errors:
Microsoft OLE DB Provider for SQL Server error '80040e07'
The conversion of a char data type to a datetime data type resulted in an
out-of-range datetime value.
/processreg.asp, line 140
US format (07/26/2002) works fine.
Is there a workaround / setting on the server that can be changed, or will I
have to write code to swap the DD/MM around?
Thanks!
(eg 26/07/2002) it errors:
Microsoft OLE DB Provider for SQL Server error '80040e07'
The conversion of a char data type to a datetime data type resulted in an
out-of-range datetime value.
/processreg.asp, line 140
US format (07/26/2002) works fine.
Is there a workaround / setting on the server that can be changed, or will I
have to write code to swap the DD/MM around?
Thanks!
#4
Ok, I'll juggle the date about in the code.
Or at least I would do if my date picker still worked... for some reason <%=now%> on my Win 2000 test server returns a 4 digit year, yet our live NT webserver will only return a 2 digit.
I've set the regional date setting to dd/MM/yyyy but <%=now%> returns "7/26/02 12:36:50 PM". The same regional settings on my 2k server return "26/07/2002 12:37:51".
I've rebooted just to be sure. Any ideas's where I've missed something?
Thanks!
Or at least I would do if my date picker still worked... for some reason <%=now%> on my Win 2000 test server returns a 4 digit year, yet our live NT webserver will only return a 2 digit.
I've set the regional date setting to dd/MM/yyyy but <%=now%> returns "7/26/02 12:36:50 PM". The same regional settings on my 2k server return "26/07/2002 12:37:51".
I've rebooted just to be sure. Any ideas's where I've missed something?
Thanks!
#5
Have you definitely set the DEFAULT system locale on WinNT? On Win2K it's controlpanel->regional settings->system default. On winNT it's cpl->regional settings then make sure you check "set as system default locale".
You may find that your host has variable system locales set, so I'd recommend building your own. The problem comes from ASP not supporting VB's "format" command, only formatDateTime which uses, guess what, system locale again so you need to use something like
dim strDateTime
dim varDate
varDate=Now()
strDateTime=Day(varDate) & "/" & Month(varDate) & "/" & Year(varDate)
Sucks, doesn't it?
You may find that your host has variable system locales set, so I'd recommend building your own. The problem comes from ASP not supporting VB's "format" command, only formatDateTime which uses, guess what, system locale again so you need to use something like
dim strDateTime
dim varDate
varDate=Now()
strDateTime=Day(varDate) & "/" & Month(varDate) & "/" & Year(varDate)
Sucks, doesn't it?
#6
try this: (by the looks of things you are using ASP)
<%=formatdatetime(now(), 1)%>
The 1 operator will set your date like "28 July 2002"
you can also use 2, 3 or 4 for differing formats.
Rich
<%=formatdatetime(now(), 1)%>
The 1 operator will set your date like "28 July 2002"
you can also use 2, 3 or 4 for differing formats.
Rich
Trending Topics
#9
Another thing....
If your Web Server is running on Win2K with Sp2 or higher there are some other issues you need to remember.
Add...
session.LCID = 2057
Into the code (usually your page include) to force the Locale the IIS user runs as. Essentially now the default system locale is not used.... see Q306044 in the Microsoft Knowledgebase for more detials..
Ids
If your Web Server is running on Win2K with Sp2 or higher there are some other issues you need to remember.
Add...
session.LCID = 2057
Into the code (usually your page include) to force the Locale the IIS user runs as. Essentially now the default system locale is not used.... see Q306044 in the Microsoft Knowledgebase for more detials..
Ids
Thread
Thread Starter
Forum
Replies
Last Post