List:General Discussion« Previous MessageNext Message »
From:Bryan Cantwell Date:April 22 2010 9:25pm
Subject:First and Last timestamp of the day/week / month
View as plain text  
I need to be able to get a first and last timestamp for a day a week or a
month. I have an example of what I did so far that gets me that info for a
week... but I fear that it is far more complex than it needs to be. Anyone
have a simple way to get first and last timestamp for these intervals?

SELECT
  timestamp(ADDDATE(CURDATE(), -1 * (DAYOFWEEK(CURDATE()) - 1)))
  , from_unixtime(unix_timestamp(ADDDATE(CURDATE()+6, -1 *
(DAYOFWEEK(CURDATE()) - 1)))+86399)

Thread
First and Last timestamp of the day/week / monthBryan Cantwell22 Apr
  • Re: First and Last timestamp of the day/week / monthAlister West23 Apr