1. Learn
  2. /
  3. Courses
  4. /
  5. Time Series Analysis in SQL Server

Exercise

Build dates from parts

The DATEFROMPARTS() function allows us to turn a series of numbers representing date parts into a valid DATE data type. In this exercise, we will learn how to use DATEFROMPARTS() to build dates from components in a calendar table.

Although the calendar table already has dates in it, this helps us visualize circumstances in which the base table has integer date components but no date value, which might happen when importing data from flat files directly into a database.

Instructions 1/2

undefined XP
  • 1

    Create dates from component parts in the calendar table: calendar year, calendar month, and the day of the month.

  • 2

    Create dates from the component parts of the calendar table. Use the calendar year, calendar month, and day of month.