w3resource

AdventureWorks Database: Add two days to each value in the OrderDate column

SQL Query - AdventureWorks: Exercise-113 with Solution

113 From the following table write a query in SQL to add two days to each value in the OrderDate column, to derive a new column named PromisedShipDate. Return salesorderid, orderdate, and promisedshipdate column.

Sample table: sales.salesorderheader


Click to view Full table

Sample Solution:

SELECT SalesOrderID  
    ,OrderDate   
    ,OrderDate + INTERVAL '2 day' AS PromisedShipDate
FROM Sales.SalesOrderHeader;

Sample Output:

salesorderid|orderdate              |promisedshipdate       |
------------+-----------------------+-----------------------+
       43659|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000|
       43660|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000|
       43661|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000|
       43662|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000|
       43663|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000|
       43664|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000|
       43665|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000|
       43666|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000|
       43667|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000|
       43668|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000|
       43669|2011-05-31 00:00:00.000|2011-06-02 00:00:00.000|
...	

SQL AdventureWorks Editor:

Practice Online


Contribute your code and comments through Disqus.

Previous: Obtain the salary percentile of each employee for a department.
Next: Get a newdate by adding two days with current date.


What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Share this Tutorial / Exercise on : Facebook and Twitter

SQL: Tips of the Day

Convert Timestamp to date in MySQL Query:

DATE_FORMAT(FROM_UNIXTIME(`user.registration`), '%e %b %Y') AS 'date_formatted'

Database: MySQL

Ref : https://bit.ly/3EJPnMQ