开发者

unable to search using timestamp in mysql

I have created a tim开发者_JS百科estamp field in mysql, where the date gets stored as 06/01/2010 07:55:40

Now if I try to search anything using a query like this :

select StartTime 
  from results 
 where timestamp(StartTime) = "30/09/2009"

it does not work.

even I cannot use this :

select * 
  from results 
  where StartTime between "06/01/2010 07:55:40" and "01/02/2010 07:55:40"

If I use:

select  timestamp(current_date());

...then it shows 02/03/2010 00:00:00

Should I change the format to something like 00-00-0000 ? Or can I search using the same format that is currently in the table?

Can anyone suggest please?


Use explicit format:

SELECT  *
FROM    results
WHERE   starttime = TIMESTAMP(STR_TO_DATE('02/03/2010 21:30:00', '%d/%m/%Y %H:%i:%s'));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜