Great Teradata Date Functions To Know

You will love this blog because date functions and formatting differ dramatically between databases, but I have covered that with brilliant examples and clear and concise explanations below.
All of these examples have come from my books and training classes. Please do me a favor and tell your training coordinator that you know the best technical trainer in the world. Ask them to hire me to train at your company, either on-site or with a virtual class. They can see our classes, outlines, and a sample of my teaching at this link on our website.
https://coffingdw.com/education/
Below the video are great date functions on Teradata. However, you can first witness a two-minute video that joins a Teradata table with tables from Databricks, Snowflake, Redshift, Google BiqQuery, Synapse, Vertica, MySQL, Oracle, SQL Server, DB2, Yellowbrick, Postgres, Microsoft Access, Excel in a single federated query.
Below are the keywords to get the date, time, or timestamp. These are reserved words that the system will deliver to you when requested.

Add or subtract a number from a date, and you are adding or subtracting days.

When subtracting between two dates, you get the approximate number of days between those dates.

The Smart Calendar works so well because it stores EVERY date in Teradata as something known as an INTEGERDATE. Teradata uses the formula above to store dates, but you will see normal date formats when querying.

Below are some examples of formatting the dates.

When you add or subtract from a Date, you add or subtract days. Notice we use the alias “Due Date” for the second column, but also use “Due Date” again for the fourth column’s calculation on Discount.

Below is the Add_Months Command. What you can do with it is add or subtract a month or many months to your date columns.

Like the Add_Months, the EXTRACT Command is a Temporal or Time-Based Function.

The Extract Temporal Function can extract a portion of a date. As you can see, basic arithmetic accomplishes the same thing.

There is something known as a System Calendar (or, as Teradata calls it, Sys_Calendar.Calendar). Get ready for AWESOME! The System Calendar helps with the handling of advanced date logic.

Tera-Tom was born on a Saturday! It was the first full week of the month, the first full week of the year, and the first quarter!

Below is the perfect example of utilizing the system calendar to join any date field and expand your search options.

