PDA

Click to See Complete Forum and Search --> : SQL in VB6 for Access file with dates


Caro
Oct 25th, 1999, 06:38 PM
I am using an sql to select records from an Access file and need to know what format the database expects dates in - it seems to be mm/dd/yy is there any way i can change this to dd/mm/yy?? Because this is how it is entered via the DTPicker. Thanks

smalig
Oct 25th, 1999, 07:15 PM
When you specify the criteria argument, date literals must be in U.S. format, even if you're not using the U.S. version of the Microsoft Jet database engine. For example, May 10, 1996, is written 10/5/96 in the United Kingdom and 5/10/96 in the United States. Be sure to enclose your date literals with the number sign (#) as shown in the following examples.

To find records dated May 10, 1996 in a United Kingdom database, you must use the following SQL statement:

SELECT *
FROM Orders
WHERE ShippedDate = #5/10/96#;

You can also use the DateValue function which is aware of the international settings established by Microsoft Windows. For example, use this code for the United States:

SELECT *
FROM Orders
WHERE ShippedDate = DateValue('5/10/96');

And use this code for the United Kingdom:

SELECT *
FROM Orders
WHERE ShippedDate = DateValue('10/5/96');

------------------
smalig
smalig@hotmail.com
smalig.tripod.com (http://smalig.tripod.com)

JHausmann
Oct 26th, 1999, 03:17 AM
Don't know if it's an option bbut you can change the date format in the DTP control (dataformat property, I believe)