TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-26-2009, 07:32 AM   #1 (permalink)
The Visitor
 
Join Date: Jun 2009
Posts: 3
Thanks: 0
mtsang is on a distinguished road
Default 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.
mtsang is offline  
Reply With Quote
Old 06-26-2009, 02:01 PM   #2 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,258
Thanks: 90
Wildhoney is on a distinguished road
Default

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!
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-26-2009, 02:40 PM   #3 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

How exactly are you issuing your sql query, are you generating the date? or are you hard-coding it in?
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 06-27-2009, 05:45 PM   #4 (permalink)
The Visitor
 
Join Date: Jun 2009
Posts: 3
Thanks: 0
mtsang is on a distinguished road
Default

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.
mtsang is offline  
Reply With Quote
Old 06-27-2009, 05:59 PM   #5 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,258
Thanks: 90
Wildhoney is on a distinguished road
Default

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?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
10 PHP Myths Dispelled Wildhoney General 9 06-15-2009 07:55 AM
Developing PHP extensions on Windows with VC++ - problems an article posted here eugenio Advanced PHP Programming 4 04-24-2009 04:45 PM
Connecting To access with php digitak Advanced PHP Programming 3 03-09-2009 09:23 AM
PHP Compressor Kalle Script Giveaway 8 05-28-2008 01:14 AM
Apache-like Access Contol List script for PHP Wildhoney Script Giveaway 1 01-07-2008 04:40 AM


All times are GMT. The time now is 06:28 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design