![]() |
Comparing a timestamp field
How do I do comparison on a timestamp field in MySQL? Or is it possible to use columns as data for UNIXTIME() or TIMESTAMPDIFF()? I could fix this problem fairly easily by changing the data in my MySQL timestamp column to a unix timestamp from the get go, but now that I've run into the problem I want to figure out how to fix it.
Here's an example of what I mean: PHP Code:
PHP Code:
-m |
It'd be something like the following. Simply convert the date in the database to a unix timestamp on-the-fly, and compare it against the current timestamp.
sql Code:
|
AHHHHH. Once again I was right on top of the answer, and missed it by an inch... see, I tried using UNIX_TIMESTAMP() on the column and it didn't work. I wasn't sure if you could feed it a column as a value or if you had to enter a hard coded value of some sort, but it turns out that the reason it didn't work is because I had already tried converting the timeout variables with the date() function and never changed them back. So in essence, I switched it from trying to validate 0000-00-00 00:00:00 against 2133421342 to trying to validate 2133421342 against 0000-00-00 00:00:00 . *rolls eyes*
It never ends... never. -m |
| All times are GMT. The time now is 01:23 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0