My Assistant
![]() ![]() |
|
|
Feb 22 2005, 12:45 PM
Post
#1
|
|
|
UtterAccess Guru Posts: 637 From: Gloucester UK |
Hi Guys
I have a text box on a form that displays a date (e.g 02 Oct 2003) I run a procedure which ioncludes the line: strSQL = strSQL & " AND ((MasterDatabase.Field24)<=#" & Me.TxtLapsedDate + Me.TxtPreLapsedDays & "#);" When I look at the query in design mode - the date has miraculously changed to #10/03/2003# AAARRRGGGHHH Any suggestions? Cheers John |
|
|
|
Feb 22 2005, 12:59 PM
Post
#2
|
|
|
UtterAccess VIP Posts: 3,893 From: Lansing, Michigan, USA |
What is the date value supposed to be?
The one you've got in there will be read by access as October 3rd 2003, regardless of your regional settings. -AJ |
|
|
|
Feb 22 2005, 01:01 PM
Post
#3
|
|
|
UtterAccess Guru Posts: 637 From: Gloucester UK |
Hi
I want it to be October the 3rd - but the query reads it as March the 10th J |
|
|
|
Feb 22 2005, 01:07 PM
Post
#4
|
|
|
UtterAccess VIP Posts: 3,893 From: Lansing, Michigan, USA |
Are you sure its reading it as March 10? Date values denoted by the # symbols are read in mm/dd/yyyy format if doing so makes a valid date, regardless of regional settings.
However, the best way to avoid the problem altogether is to force the date into a non-ambiguous format. Try the following code. strSQL = strSQL & " AND ((MasterDatabase.Field24)<=#" & Format(Me.TxtLapsedDate + Me.TxtPreLapsedDays, "dd-mmm-yyyy") & "#);" Then the date value in the resulting SQL should be #03-Oct-2003#, which cannot possibly misinterpreted by the database engine. -AJ |
|
|
|
Feb 22 2005, 01:32 PM
Post
#5
|
|
|
UtterAccess Guru Posts: 637 From: Gloucester UK |
Thanks AJ - I'll give it a try
Cheers John |
|
|
|
Feb 22 2005, 01:47 PM
Post
#6
|
|
|
UtterAccess Guru Posts: 637 From: Gloucester UK |
Hi AJ
That's worked a treat - many thanks John |
|
|
|
Feb 22 2005, 02:20 PM
Post
#7
|
|
|
UtterAccess VIP Posts: 3,893 From: Lansing, Michigan, USA |
Great! Glad you got it working, and I'm happy to help.
-AJ |
|
|
|
Feb 22 2005, 02:50 PM
Post
#8
|
|
|
UA Editor + Utterly Certified Posts: 22,725 From: Melton Mowbray,Leicestershire (U.K) |
Hi John
Just as an added reference about dates in SQL's.. International Dates in Access May prove useful one day. Which would come first the earth freezing over or we all get to use the same date format....(I can feel the temperature dropping) (IMG:http://www.utteraccess.com/forum/style_emoticons/default/thumbup.gif) |
|
|
|
Feb 22 2005, 02:55 PM
Post
#9
|
|
|
UtterAccess Guru Posts: 637 From: Gloucester UK |
Hi Larry
Thanks very much - looks useful Cheers John |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 18th June 2013 - 08:48 PM |