Here’s an example to extract year from timestamp using DATE_TRUNC function.

DATE_TRUCN Function

DATE_TRUNC ( PERIODIC_DATE, YEAR)

The TRUNC function truncates DATE to year. The input DATE is YYYY-MM-DD. After TRUNC function, it changes to YEAR. That means to YYYY-01-01.

Uses of DATE_TRUNC Function

  • This function most frequently being used in data warehousing projects.
  • This is one of the best way to work with Date related functions.

References

Related Posts

Fediverse reactions

Discover more from Srinimf

Subscribe now to keep reading and get access to the full archive.

Continue reading