Home » Microsoft » 70-461 v.2 » Which function should you use?
You develop a Microsoft SQL Server database that contains a table named Employee, defined as follows:
You need to create a view that contains two computed columns representing the month and the year of the [HireDate] of each Employee.
Which function should you use?
A. DATENAME( )
B. CONVERT( )
C. TRYDATEDIFF( )
D. MONTH( ) and YEAR( )
Correct Answer: D
Explanation/Reference:
Explanation:
The Month function returns an integer that represents the month of the specified date.
The Year function an integer that represents the year of the specified date.
References:
https://docs.microsoft.com/en-us/sql/t-sql/functions/month-transact-sql?view=sql-server-2017 https://docs.microsoft.com/en-us/sql/t-sql/functions/year-transact-sql?view=sql-server-2017