Getting Date Functions in SQL - Issue 136
A quick lookup one-pager for common DATE functions in SQL
Recently I received a request to break down common SQL Date functions but make them “business user-friendly” 🤔☠️.
My natural response to PMs, business, and marketing partners who ask if they should learn SQL to be better at their job is NO, because:
Not-optimized queries or SELECT* in production in RedShift or Postgres bring nothing but a wailing and great looming despair to the one and only DE person in house.
There are so many tools out there that aim to take this burden from you, show you data at your fingertips, and save you many hours of learning SQL. Many of these tools are free or becoming more affordable even if you have a tight budget (e.g. Google Analytics, Adobe Analytics, Firebase, Appfigures, Clicky, Hotjar, HubSpot, Smartlook, Bitly, and Google Search Console. I believe Mixpanel and Heap also both have a free basic plan).
There is so much context required on the data source, data value, and limitations of that table you query, and that context is crucial to the question you want to answer. Unless you are involved in every stage of that event or transaction data lifecycle and understand all in and outs, you are likely to get the wrong data or misleading data.
Normally, I am not a fan of democratizing SQL usage for product or business stakeholders, because, in 98% of cases that I’ve experienced, an analyst has had to redo the pull, and then restate the numbers, and then correct assumptions.
But it has been a difficult week, and we all would appreciate a distraction from financial markets analysis and commentary. When the world goes dark and uncertain, I find it’s best to be reminded of the foundation that holds all of us together: family, friends, and a relational database.
So I decided to do just that this week - publish a SQL guide on Date and Time formatting, hopefully making it business user-friendly and providing pointers on which function to use for which question or case.
Keep reading with a 7-day free trial
Subscribe to Data Analysis Journal to keep reading this post and get 7 days of free access to the full post archives.