开发者

Mysql time stamp queries

I have a column that uses time stamp. My question is I am a bit confused about how to make queries against it,how would I say

Where $time is after X date

Are queries made in local time or CUT?

When I just 开发者_如何学JAVAtry to do where andthe post date /time I get an error because of the space and if I quote it I think it takes it as a string : /

What format do I use for the date in the WHERE clauss !?!?


You can use the normal logical comparisons, for example:

SELECT * FROM table WHERE date >= '2010-01-31'
SELECT * FROM table WHERE date >= '2010-01-31 12:01:01'

Time is generally in your current local time, but you can run the query "SELECT CURTIME()" to check. Also, make sure you have the year-month-date in the right order... that can cause issues.

The manual has more details:

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html


Assuming you talk about TIMESTAMP column type (not Unix timestamp) the format is either 'YYYY-MM-DD HH:MM:SS' (quoted) or YYYYMMDDHHMMSS

Atually, in the first case you can use any spearators you wish (or none), only numbers are taken into ccount

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜