Below is great information about date functions on Snowflake. Just above the date information is something even more amazing. Witness a two-minute video that joins tables from Databricks, Snowflake, Redshift, Azure Synapse, BigQuery, Teradata, Oracle, SQL Server, DB2, Yellowbrick, Vertica, MySQL, Postgres, Microsoft Access, and Excel in a single federated query.
You can now download our books on Synapse, Redshift, Google BigQuery, DB2, Oracle, Yellowbrick, Vertica, MySQL, Postgres, and more for FREE.
You can download the PDFs from our CoffingDW.com website immediately.
Here is how you do it. Go to CoffingDW.com and click on Books from the top right menu. You will then be in the CoffingDW bookstore, where you will see the Snowflake book. Add the Snowflake book to your cart.
Add any book you want to your cart.
When you check out, you use the coupon FRIEND2023.
You won’t have to enter any credit card information. Just put in your name and email, and the price will be discounted to zero. You can then download the book immediately at no cost to you.
In the example below, the current_date will return today’s date. Add or subtract a number from the CURRENT_DATE, and you are adding or subtracting days from the date. If you subtract from two dates, you get the number of days between the two dates.
The Dateadd command below adds a specified time interval to a date or timestamp value.
The DATEADD and ADD_MONTHS function below handle dates that fall differently at the ends of months.
You can use the TO_CHAR function below to format dates.
You can use the techniques below to extract or use the EXTRACT command, which is ANSI compliant.
Here are some great date functions to round out your toolkit.
The DATEDIFF command takes a datepart and returns the difference between two dates or timestamps.
TIME_SLICE calculates the beginning or end of a “slice” of time, where the slice length is a multiple of a standard unit of time, such as minute, hour, day, etc.
If your company needs Snowflake training, Tera-Tom Coffing is the best trainer in the industry, with over 1,000 classes under his belt. Tom will customize the course around your needs. Check out the link to see the course agenda and outline. https://www.nexusdataserver.com/snowflakeclass.
If you are migrating data to Snowflake, the best tool is the Nexus Server, which migrates every database to Snowflake with the click of the mouse. I have a major insurer migrating tens of thousands of tables directly from Netezza, Oracle, and Teradata to Snowflake. Check out this YouTube video to see how easy data migrations can be with Nexus. https://www.youtube.com/watch?v=_9ABivdwJPk.
Please contact Tom Coffing at Tom.Coffing@CoffingDW.com or phone 513 300-0341 to speak with Tom Coffing.
Tom Coffing, better known as Tera-Tom, founded Coffing Data Warehousing, where he has been CEO for the past 30 years. Tom has written over 90 books on Architecture, performance tuning, and SQL on all relevant systems. Tom has taught over 1,000 classes worldwide, and he is the designer of the Nexus, which celebrates 20 years of brilliantly integrating all databases.