Skip to main content

Time Series Analysis in SQL Server

Explore ways to work with date and time data in SQL Server for time series analysis

Start Course for Free
5 Hours16 Videos60 Exercises16,535 Learners
5150 XP

Create Your Free Account



By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA. You confirm you are at least 16 years old (13 if you are an authorized Classrooms user).

Loved by learners at thousands of companies

Course Description

SQL Server has a robust set of tools to prepare, aggregate, and query time series data. This course will show you how to build and work with dates, parse dates from strings (and deal with invalid strings), and format dates for reporting. From there, you will see how SQL Server's built-in aggregation operators and window functions can solve important business problems like calculating running totals, finding moving averages, and displaying month-over-month differences using realistic sample data sets. You will also see how taking a different perspective on your data can solve difficult problems.

  1. 1

    Working with Dates and Times


    This chapter covers date and time functionality in SQL Server, including building dates from component parts, formatting dates for reporting, and working with calendar tables.

    Play Chapter Now
    Building dates
    50 xp
    Break out a date into year, month, and day
    100 xp
    Break a date and time into component parts
    100 xp
    Date math and leap years
    100 xp
    Rounding dates
    100 xp
    Formatting dates for reporting
    50 xp
    Formatting dates with CAST() and CONVERT()
    100 xp
    Formatting dates with FORMAT()
    100 xp
    Working with calendar tables
    50 xp
    The benefits of calendar tables
    50 xp
    Try out a calendar table
    100 xp
    Joining to a calendar table
    100 xp

In the following tracks

Data AnalystSQL Server Fundamentals


Chester IsmayMona Khalil
Kevin Feasel Headshot

Kevin Feasel

CTO, Envizage

Kevin is a Microsoft Data Platform MVP and CTO at Envizage, where he specializes in data analytics with T-SQL and R, forcing Spark clusters to do his bidding, fighting with Kafka, and pulling rabbits out of hats on demand. He is the lead contributor to Curated SQL ( and author of PolyBase Revealed (forthcoming). A resident of Durham, North Carolina, he can be found cycling the trails along the triangle whenever the weather's nice enough.
See More

What do other learners have to say?

I've used other sites—Coursera, Udacity, things like that—but DataCamp's been the one that I've stuck with.

Devon Edwards Joseph
Lloyds Banking Group

DataCamp is the top resource I recommend for learning data science.

Louis Maiden
Harvard Business School

DataCamp is by far my favorite website to learn from.

Ronald Bowers
Decision Science Analytics, USAA