24.3k views
4 votes
Write a SELECT statement that returns these columns from the Orders table: The OrderDate column A column that returns the four-digit year that’s stored in the OrderDate column A column that returns only the day of the month that’s stored in the OrderDate column. A column that returns the result from adding thirty days to the OrderDate column.

1 Answer

5 votes

In a database date data type is stored with date and time. Default return of date data type default on the database date setting.

Step-by-step explanation:

Some database returns on date which contains day, month number, and year two digit number.

In sql server 2014

Select format (OrderDate, ‘yyyy’) [order year] , format (OrderDate, ‘dd’) [order days] , dateadd(day,30, OrderDate) [orderday30] from orderstable.

First column [order year] return the four year of each rows.

[Order days] return the day number of each rows.

[orderday30] returns by adding 30 of each rows.

User Underrun
by
5.6k points