DIFFERENT DATETIME FORMATS WITH CURRENT DATETIME IN SQL SERVER.
For example the current date time is :
SELECT GETDATE() AS CURRENT_DATE_TIME
CURRENT_DATE_TIME: "2020-07-06 23:17:10.490"
SELECT CONVERT(VARCHAR(10),GETDATE(),101) AS DATE1
-- DATE1 : "07/06/2020"
SELECT CONVERT(VARCHAR(10),GETDATE(),102) AS DATE2
-- DATE2 : "2020.07.06"
SELECT CONVERT(VARCHAR(10),GETDATE(),103) AS DATE3
-- DATE3 : "06/07/2020"
SELECT CONVERT(VARCHAR(10),GETDATE(),104) AS DATE4
-- DATE4 : "06.07.2020"
SELECT CONVERT(VARCHAR(10),GETDATE(),105) AS DATE5
-- DATE5 : "06-07-2020"
SELECT CONVERT(VARCHAR(11),GETDATE(),106) AS DATE6
-- DATE6 : "06 Jul 2020"
SELECT CONVERT(VARCHAR(12),GETDATE(),107) AS DATE7
-- DATE7 : "Jul 06, 2020"
SELECT CONVERT(VARCHAR(12),GETDATE(),108) AS DATE8
-- DATE8 : "23:13:55"
SELECT CONVERT(VARCHAR(11),GETDATE(),109) AS DATE9
-- DATE9 : "Jul 6 2020"
SELECT CONVERT(VARCHAR(10),GETDATE(),110) AS DATE10
-- DATE10 : "07-06-2020"
SELECT CONVERT(VARCHAR(10),GETDATE(),111) AS DATE11
-- DATE11 : "2020/07/06"
SELECT CONVERT(VARCHAR(10),GETDATE(),112) AS DATE12
-- DATE12 : "20200706"
SELECT CONVERT(VARCHAR(11),GETDATE(),113) AS DATE13
-- DATE13 : "06 Jul 2020"
SELECT CONVERT(VARCHAR(11),GETDATE(),114) AS DATE14
-- DATE14 : "23:15:27:50"
Please see the below screenshot for the clarifications.
- - - - - - Cheers, Happy to Help! - - - - - -
No comments:
Post a Comment