calendar control and date format

B

bigrav

Hi I'm trying to run a query in some code.

However it seems apparent that when matching with dates against date
field in a query the convention being used is the american
one(mm/dd/yy) and not the british form of dd/mm/yy.

is there a way to convert this form to american formar?
 
M

Michel Walsh

Hi,


If you refer to the container of the date, as a control or as a field, you
don't need to format anything, since the data is already stored internally.

Only when you need to insert an immediate constant must you care about the
right encoding. In general, ## delimiter will assume your date is in a US
format, and only if it finds it incoherent, would OLEAUT32 tries alternates
patterns to see if it can make sense of reading it as a date.

To avoid miss-interpretation, you can force a US setting.

strSQL = " ... #" & myDateTime & "# ... "

can result in a problem, mainly if the Regional Setting format dates in a
different sequence than in the US sequence (month, day, year). So:


strSQL = "... #" & Format( myDateTime, "mm/dd/yyyy") & "# ... "


would not be dependant of the Regional Setting! An note that you should not
try to control a USER setting, since it IS just that, a USER setting. So,
forcing the format would make your application more robust.


Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top