I have looked at several of the tutorials on using dates with PHP and MySql and I'll admit I am lost.
I have a date field in my database that is receiving the data from a desktop application and the data is being stored correctly on my server in the following format - 2007-06-18 - now I want to give users the ability to pull data by a range of dates.
Since php passes the data in strings I assume I must use a function of some sort, but I'm not sure which one or should I use a MySql function or a PHP function? Would someone please point me to a concise tutorial or a sample code that I could study?
Thank you
Completely Confused by Date Functions
Moderator: General Moderators
-
PastorHank
- Forum Contributor
- Posts: 117
- Joined: Sat Jun 03, 2006 7:58 am
- Location: Texas Hill Country
mysql converts strings of the format 'yyy-mm-dd' into dates as needed.
e.g.
e.g.
Code: Select all
SELECT x,y,z FROM tbl WHERE datefiled between '2006-05-01' AND '2007-05-31'- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Dates in MySQL are like strings. You can order them by alphabetical order (which also includes numbers).
Code: Select all
SELECT `column` FROM `table` WHERE `date` < '2007-06-19' ORDER BY `date` DESC;-
PastorHank
- Forum Contributor
- Posts: 117
- Joined: Sat Jun 03, 2006 7:58 am
- Location: Texas Hill Country