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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where can I learn more about DATE and TIME functions??

Status
Not open for further replies.

blakekr

Programmer
Joined
Jul 19, 2000
Messages
11
Location
US
I'm new to mySQL and trying to convert a fairly complex program to it.

Most of my tables have an unofficial key which is a timestamp stored as DATETIME, to keep it static.

I would like to take some of my longer, more elaborate perl time-handling functions and use the mySQL built-in ones instead. But I can't seem to find any good guides to doing so. Not on the mySQL site and definitely not in the perl-DBI book (a disappointment to me).

I am trying to figure out probably-simple things like:

- how to get perl to return the results of a
SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(), '%Y-%m-%d')
...command.

- how to efficiently
SELECT * FROM myTable WHERE {e.g., month=(n) months before current month, in the datetime column, format YYYY-MM-DD HH:MI:SS}
... using mySQL commands as opposed to some silly hack.

The script is very date-centric and I would love to be doing things RIGHT as opposed doing things kluged.

Does anyone have any suggestions for finding out how to do this gracefully, or even a suggestion of a well-written date-centric mySQL script I could examine?

Thank you for all thoughts!



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top