开发者

Get a condition based select query

select initial_time, closing_date, length_of_duration(in minutes) from table1;

initial_time is in date time stamp (ex:2011-02-14 20:35:00)
closing_date is in date (for ex:2011-02-14)
length_of_dura开发者_运维知识库tion in minutes (5)

I want to get 0 or 1 (ie true or false) if :

For true:

Current time stamp is greater than (initial_time + length_of_duration less than closing_date);

For ex: If current time stamp is 2011-02-14 21:35:00 & initial_time -2011-02-14 20:35:00, length-5 mins and closing date is 2011-02-14, since current time is greater than these, it should return true.

Any thoughts to get this output based on select query in mysql? Thanks.


if (date_add(initial_time , interval length_of_duration minute)
  <=concat(closing_date, ' 23:59:59'), 1, 0)

reason to use 23:59:59 assuming the cut-off date is before 2011-02-15,
which is 2011-02-14 23:59:59

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜