It will depend on the database you're using! As you can see below, there can be quite some variations in syntax between Vertica, SQL Server, MySQL, PostgreSQL So, what's common in all these examples? In all cases, you will need: a function that gets the current date a function that extracts the year from … Continue reading How can I get the end date of a quarter with SQL?
Yesterday, we looked at the standard approach of aggregating daily data stretching over a longer time periods If you're lucky enough to be working with Vertica or MySQL, you can also rely on functions like: year(), quarter(), month(), week(), day() SQL Server also supports some of them - year(), month(), day() - but is by far the most limited of … Continue reading How do I extract part of a date with SQL? (2)
Have you ever had that request? I would like to have the distribution of clicks per hour for the last week in local time It's a no brainer if your database server is in the same time zone as your business audience - then you just need to aggreate the clicks' timestamps to an hour. Not … Continue reading How do I convert a timestamp to another timezone with SQL?