shantanuo
shantanuo

Reputation: 32326

Rewriting a query

$gettmm = "SELECT min(date_format(lastupdate,'%H:%i')), max(date_format(lastupdate,'%H:%i')) FROM my_table WHERE lastupdateid='".$key1."' and date_format(lastupdate,'%Y-%m-%d')='".$search_date."'";

I need to change the date comparision. I prefer between as shown below.

and lastupdate between ('2013-08-13 00:00:00') and ('2013-08-13 23:59:59') ;

The variable $search_date is 2013-08-13 and I need to concat it with 00 and 23 in order to make it suitable for between clause. How to write the appropriate PHP code for this.

Upvotes: 0

Views: 70

Answers (1)

sam yi
sam yi

Reputation: 4934

In this case, I prefer doing this instead of using "BETWEEN"

and lastupdate >= '2013-08-13 and < '2013-08-14'

Upvotes: 2

Related Questions