How do I find the next Monday/Tuesday/etc.. with SQL?

Being able to calculate the date of the coming Thursday may come really handy if your sales revenue follows a very strong weekday pattern as it enables you to use weekdays, rather than fixed dates, as a basis for making your weekly financial projections. How do I do this in practice? Vertica offers a very … Continue reading How do I find the next Monday/Tuesday/etc.. with SQL?

How do I find the first day of previous/next week with SQL?

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?

How do I calculate the remaining days until the end of a fiscal quarter?

Should you work for a public company, it is very likely that the fiscal year of your company may not be the same as the calendar year. This in turn, means, that a bunch of your analyses may need to forecast financials for the fiscal quarters, rather than the calendar ones. How could you then … Continue reading How do I calculate the remaining days until the end of a fiscal quarter?

How do I calculate the remaining days until the end of a calendar quarter?

It may sound overwhelming but it's actually quite simple, especially if you've already figured out how to: extract various time periods from a date get the end date of the current quarter calculate the number of days between two days As you'll see below - calculating the remaining days in current quarter is then nothing … Continue reading How do I calculate the remaining days until the end of a calendar quarter?

How can I get the end date of a quarter with SQL?

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?

How do I convert string to a date with SQL?

Hit a couple of error messages when trying to convert a string to a date? And that's totally not surprising! As you'll see below the text-to-date conversion functions within the different database environments seldom have identical syntax Why would you want to convert a string to a date? Well, it could be pretty useful if … Continue reading How do I convert string to a date with SQL?