![]() |
PHP Access Date problems.
Hello Hi, :)
First time here and 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. |
It seems as though it's mixing up the day and month. I don't know to solve that, unfortunately.
Is it when you attempt to query it through PHP that it appears to reverse the day and month? Welcome to the community, by the way :-) Your first question is a peculiar little problem! |
How exactly are you issuing your sql query, are you generating the date? or are you hard-coding it in?
|
Hi. Thanks for the reply :)
yeah, i kind of hard code it or more accurate, I let user to input a date in format of dd/mm/yyyy so, i have the code below. $dDate = $_POST["dDate"]; then, i connect using odbc driver and run below codes to pass the sql to access. $sql = "select * from staff where (datevalue(staff.entry) > datevalue('$dDate'))"; $result = odbc_exec ($conn, $sql); after that, i retrieve result. Hope this helps. Thanks very much. |
Okay. So you're asking the user to put the date in the format of DD/MM/YYYY, whereas your database is storing it in the format of MM/DD/YYYY?
|
| All times are GMT. The time now is 12:59 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0