Hey guys you won't believe this ,I just spend nearly three hours in just searching for mysql command to get the current date and time of yesterday .It may seem funny and silly to you, but it really took my time .Its been problem with me all days ,I won't read anything to the core ,will just understand the basics of it and try to figure other things out of it .Mostly my principle won many times ,but these are some times where my principle failed. Fine this is my state where I need to finish a imaginative script (assume everythings and write it) within evening . I just finished my coding part and it was a time to get some information on previous dates from MYSQL table .

I know current_timestamp () will give the current timestamp ,but I just want to get the current yesterday time . My search keeps on going in all patterns of key words ,but the result is 404 . Finally after three hours I got this keyword interval from some where around fifth result page of google. This is it.

select current_timestamp();

'2009-09-04 09:33:53'

select current_timestamp() - interval 1 day ;

'2009-09-03 09:33:53'

select current_timestamp() - interval 1 hour ;

'2009-09-03 03:33:53'

select current_timestamp() - interval 1 minute ;

'2009-09-03 03:32:53'

select current_timestamp() - interval 1 second ;

'2009-09-03 03:33:52'

Hope it may help some guys like me at some point .

Related Posts :



Bookmark and Share