You would like to display the system date in the format "Monday, 01 June, 21". Which SELECT statement should you use?
Question
You would like to display the system date in the format "Monday, 01 June, 21". Which SELECT statement should you use?
Solution
In SQL, you can use the GETDATE()
function to get the current date and time. However, to format it in the way you want, you can use the FORMAT()
function. Here is the SQL statement you should use:
SELECT FORMAT ( GETDATE(), 'dddd, dd MMMM, yy' ) as Date;
Here's what it does:
GETDATE()
gets the current date and time.FORMAT()
is a function that formats the date and time in a specified format.'dddd, dd MMMM, yy'
is the format string.dddd
represents the full name of the day of the week,dd
represents the day of the month as a number,MMMM
represents the full name of the month, andyy
represents the year as a two-digit number.as Date
gives the column a name.
Similar Questions
What is the proper way to write a DATE data type in SQL?1 pointDD-MM-YYYYYYYY/MM/DDYYYY-MM-DDDD/MM/YYYY
What would be the output of the following query, assuming 2-DEC-2018 is the system date?
4. Which command is used by the system administrator to set the date of the system?*1 pointa) dtb) suc) dated) chdt
This is used to get the day my daughter was born SELECT DAYNAME(<date_expression>)Group of answer choicesTrueFalse
Select the correct answerHow is Date stored in database?Optionsjava.util.Datejava.sql.Datejava.sql.DateTimejava.util.DateTime
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.