SHARE
TWEET

Untitled

a guest Jul 20th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. TIMESTAMP(DATE_FORMAT(timestamp, '%Y-%m-01'))
  2.      
  3. SELECT CONCAT(YEAR(timestamp), '/', WEEK(timestamp)), etc...
  4. FROM ...
  5. WHERE ..
  6. GROUP BY CONCAT(YEAR(timestamp), '/', WEEK(timestamp))
  7.      
  8. 2012/1
  9. 2012/10
  10. 2012/11
  11. ...
  12. 2012/19
  13. 2012/2
  14.      
  15. SELECT CONCAT(YEAR(date), '/', WEEK(date)) AS week_name,
  16.        YEAR(date), WEEK(date), COUNT(*)
  17. FROM column_name
  18. GROUP BY week_name
  19. ORDER BY YEAR(DATE) ASC, WEEK(date) ASC
  20.      
  21. YEAR/WEEK   YEAR   WEEK   COUNT
  22. 2011/51     2011    51      15
  23. 2011/52     2011    52      14
  24. 2012/1      2012    1       20
  25. 2012/2      2012    2       14
  26. 2012/3      2012    3       19
  27. 2012/4      2012    4       19
  28.      
  29. FROM_DAYS(TO_DAYS(TIMESTAMP) -MOD(TO_DAYS(TIMESTAMP) -1, 7))
  30.      
  31. DATE_SUB( field, INTERVAL DAYOFWEEK( field ) - 1 DAY )
  32.      
  33. DATE_FORMAT($yourDate, '%X %V') as week
  34.      
  35. group_by(week);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top