View Full Version : PHP Access Date problems.


Jiraiya-Sama
06-25-2009, 11:49 PM
Hello Hi, :)

I have a problem about date format (dd/mm/yyyy or mm/dd/yyyy........) and hope if anyone can give me some ideas.

ok, i have a php running and using odbc to connect to a access database.
i need to do some date comparison in access database.

so, i have a sql doing this to filter all staff entry date that is later than 1.June.2009
select * from staff where (datevalue(staff.entry) > datevalue('1/6/2009'))

However, when i execute this sql in php, it becomes filter staff entry date that is later than 6.Jan.2009

Funny thing is, when i try to run the exact same SQL in access directly, it understands that it is 1.June.2009.

could anyone give me some hints or ideas why it is?

by the way, if it helps, in my window regional setting, the date format is d/M/y.

Thanks a million.

namliam
06-26-2009, 02:01 AM
The problem is... When your actually working in Access it uses your Regional settings.
When using ODBC, it works on its OWN....

Access NEEDS MM/DD/YYYY, no questions asked. So use MM/DD/YYYY.
Why use datevalue and not ie. DateSerial ??? That lets you specify the exact date in Day, Month, Year without ever wondering (guarantee) if it goes well...

When in doubt, use DateSerial or MM/DD/YYYY!!!