in reply to Re: MySQL Timestamp comparison
in thread MySQL Timestamp comparison
This isn't necessary. The UNIX_TIMESTAMP MySQL function takes a datetime (any date type column) as an argument and returns the epoch of the time passed; such as: SELECT UNIX_TIMESTAMP(myDateCol) FROM TABLE;
Also, MySQL has another function called INTERVAL that allows you to do math on the date in the database itself, such as: select * from table where myDateCol < current_date - interval 5 day; will show you everything older than five days ago.
When doing database programming, the hardest thing for me to get over was to try and do everything in the program (in Perl, in C, etc) when the database is (in _most_ cases) going to be able to do it for you a lot more efficiently and a lot faster. Let the database do it's job.. it likes it, really.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: MySQL Timestamp comparison
by hmerrill (Friar) on Oct 30, 2003 at 15:59 UTC | |
by erasei (Pilgrim) on Oct 30, 2003 at 16:46 UTC | |
by Ninthwave (Chaplain) on Oct 30, 2003 at 20:57 UTC | |
by hmerrill (Friar) on Oct 30, 2003 at 22:25 UTC |