Answer:
SELECT order_id, order_date,
DATEADD(DAY,5,order_date) AS approx_ship_date,
ship_date,
DATEDIFF(DAY,ship_date,DATEADD(DAY,2,order_date)) AS days_to_ship
FROM Orders
WHERE YEAR(order_date) = 2018 AND MONTH(order_date) = 3
Step-by-step explanation:
The first line of the SQL statement is a SELECT statement which selects order_id, order_date and ship_date columns from Orders table.
The DATEADD() is used to add date and here it is used to add 5 days to order_date column and the resultant column is named as approx_ship_date using ALIAS.
DATEDIFF() function is used to return the difference between two dates and here it shows number of days between order_date and ship_date columns.
WHERE clause is used to retrieve orders from March 2018. YEAR function represents the year of order_date which is set as 2018 to retrieve the orders for 2018. MONTH function represents the month of order_date which is set to 3 which means March in order to retrieve the orders for March.