Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

SQL Server 2000 not accepting UK format dates.

Thread Tools
 
Search this Thread
 
Old 26 July 2002, 12:11 PM
  #1  
AdrianFRST
Scooby Regular
Thread Starter
 
AdrianFRST's Avatar
 
Join Date: Oct 2000
Posts: 368
Likes: 0
Received 0 Likes on 0 Posts
Question

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!
Old 26 July 2002, 12:15 PM
  #2  
Dizzy
Scooby Regular
 
Dizzy's Avatar
 
Join Date: May 2001
Posts: 2,537
Likes: 0
Received 0 Likes on 0 Posts
Post

isn't that locals on the actual server... I'll have a look @ our servers here back later
Old 26 July 2002, 12:22 PM
  #3  
chiark
Scooby Regular
 
chiark's Avatar
 
Join Date: Jun 2000
Posts: 13,735
Likes: 0
Received 0 Likes on 0 Posts
Post

Use # characters around the date, and always use US format. At least this way it *always* works, no matter what the server's default locale is set to.
Old 26 July 2002, 01:06 PM
  #4  
AdrianFRST
Scooby Regular
Thread Starter
 
AdrianFRST's Avatar
 
Join Date: Oct 2000
Posts: 368
Likes: 0
Received 0 Likes on 0 Posts
Post

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!
Old 26 July 2002, 02:07 PM
  #5  
chiark
Scooby Regular
 
chiark's Avatar
 
Join Date: Jun 2000
Posts: 13,735
Likes: 0
Received 0 Likes on 0 Posts
Post

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?
Old 26 July 2002, 03:24 PM
  #6  
SJ_Skyline
Scooby Senior
 
SJ_Skyline's Avatar
 
Join Date: Apr 2002
Location: Limbo
Posts: 21,922
Likes: 0
Received 1 Like on 1 Post
Thumbs up

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
Old 26 July 2002, 03:46 PM
  #7  
chiark
Scooby Regular
 
chiark's Avatar
 
Join Date: Jun 2000
Posts: 13,735
Likes: 0
Received 0 Likes on 0 Posts
Post

...as long as your system locale is set correctly!
Old 26 July 2002, 04:44 PM
  #8  
ChristianR
Scooby Regular
iTrader: (1)
 
ChristianR's Avatar
 
Join Date: May 2001
Location: Europe
Posts: 6,329
Likes: 0
Received 1 Like on 1 Post
Post

change your local settings (under regional settings) on your live nt server to have yyyy instead of yy for the date.
Old 26 July 2002, 05:17 PM
  #9  
ids
Scooby Regular
 
ids's Avatar
 
Join Date: May 1999
Posts: 424
Likes: 0
Received 0 Likes on 0 Posts
Post

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
Old 26 July 2002, 05:49 PM
  #10  
TopBanana
Scooby Regular
 
TopBanana's Avatar
 
Join Date: Jan 2001
Posts: 9,781
Likes: 0
Received 0 Likes on 0 Posts
Post

SET DATEFORMAT dmy
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
S600HBY
Subaru Parts
8
03 October 2015 05:14 PM
Lillyart14
ScoobyNet General
24
01 October 2015 01:29 AM
madmover
Member's Gallery
4
28 September 2015 10:46 AM
Littleted
Computer & Technology Related
0
25 September 2015 08:44 AM



Quick Reply: SQL Server 2000 not accepting UK format dates.



All times are GMT +1. The time now is 06:55 AM.