I saw your article the other day on getting the first date of the current week.. But what if I wanted to get the first date of the previous week? Or the first date of next week? As you've already guessed, the SQL syntax for getting the first day of the current week will require … Continue reading How do I find the first day of previous/next week with SQL?
Have you ever had to do weekly/monthly reporting based on SQL data retrieval? It would be pretty neat if you could get the start date of the current week/month dynamically, no? Well, there's a very straightforward way if you're using Vertica or PostgreSQL - just employ the date_trunc('period', timestamp) function. Other databases (e.g. SQL Server, MySQL) … Continue reading How do I find the first day of the current week with SQL?
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?
Did you ever have to check what the status of an indicator was exactly: 2 years ago 6 months ago 3 weeks ago What is crucial in each one of those instances is the ability to calculate what the exact date at the time was, so that you're retrieving data for corresponding periods. It can … Continue reading How do I find the date that is a number of months from/before now with SQL?