How to use the DATE_TRUNC Function in SQL (vs. TO_CHAR)

Published: 12 January 2020
on channel: Becoming a Data Scientist
24,289
546

In this tutorial, you'll learn how to use the DATE_TRUNC function in SQL to optimize queries using dates!

Watch the TO_CHAR video:    • Using the TO_CHAR function in SQL Cha...  

Queries:
1) Truncate for the day: SELECT date, DATE_TRUNC('day',date) FROM table
2) Do some truncated date math: SELECT DATE_TRUNC('day',date1)-DATE_TRUNC('day',date2) FROM table

Get the Pagila Database:    • How to Load a Sample PostgreSQL Datab...  

Support the Channel:
1) Subscribe:
2) DataCamp:
3) Udacity:


Watch video How to use the DATE_TRUNC Function in SQL (vs. TO_CHAR) online without registration, duration hours minute second in high quality. This video was added by user Becoming a Data Scientist 12 January 2020, don't forget to share it with your friends and acquaintances, it has been viewed on our site 24,289 once and liked it 546 people.