DataBolt

SQL LEARNING PLATFORM

22

CHAPTER 22

Data & Time Functions

Working with dates - extraction, arithmetic, formatting.

3

Learning Blocks

SQL

Interactive Queries

In This Chapter

Concepts you'll master

1

Getting current date and time

2

Extracting year, month, day from a date

3

Calculating differences between dates

4

Adding and subtracting intervals

5

Filtering by date ranges

Example

Order from the last 90 days
SQL QUERY
SELECT order_id, order_date, total
FROM orders
WHERE order_date >= DATE_SUB(CURDATE(), INTERVAL 90 DAY);

Exercise

Practice your SQL skills

SQL EDITOR
Press semicolon (;) to auto-run query

Tasks

Complete all SQL challenges

1

Show each employee's name along with the year they were hired.

Current Task
2

Display the month number in which each employee was hired.

3

Display the month name in which each employee was hired.

4

Add 7 days to each employee's hire date and display the new date.

5

Calculate how many days each employee has worked till today.

Need help solving this task?