Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with query-ing dates in MySQL

Status
Not open for further replies.

ryan010101

Technical User
Jan 24, 2001
83
0
0
US
I have a MySQL table which has a field called "release_date". This field is a date field and the format of the date used is "CCYY-MM-DD". I need to be able to say show me all titles with release_date > today. I first tried using time() to get the current date but that doesn't work in the query since it is a unix time stamp. Is there a way to write the query so I could keep the date in the same format and have it work properly?

OR a perl script is what populates the table. Every night a csv file is generated from out inventory software and a perl script runs and updates the MySQL table with this csv file. Does anybody know an easy way in perl to change my date to a unix time stamp? The format of the date in the csv file can be changed in our software.

Any help would be appriciated.

thanks
Ryan
 
You have several choices. A query of:

select * from foo where release_date > now()

will probably work and uses only MySQL internal functions.

If you don't want to do that, check out PHP's date() function.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I would try :

Code:
SELECT * FROM table WHERE release_date > CURDATE()


CURDATE() is an internal MySql function.
--
PG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top