convert (nvarchar), count_time,121): Convert is a date conversion function, typically in the time type (Datetime,smalldatetime) and the string type (Nchar,nvarchar, Char,varchar) 3 parameters of a function that are used when converting to each other,
The 1th parameter is the converted size, the 2nd is the field or function of the converted date, and the 3rd is the converted format, as follows:
- 0 | 0 or | mon dd yyyy hh:miam (or PM)
- 1 | 101 | Mm/dd/yy
- 2 | 102 | Yy-mm-dd
- 3 | 103 | Dd/mm/yy
- 4 | 104 | Dd-mm-yy
- 5 | 105 | Dd-mm-yy
- 6 | 106 | DD Mon yy
- 7 | 107 | Mon dd,yy
- 8 | 108 | Hh:mm:ss
- 9 | 9 or 109 | Mon dd yyyy hh:mi:ss:mmmmAM (or PM)
- 10 | 110 | Mm-dd-yy
- 11 | 111 | Yy/mm/dd
- 12 | 112 | Yymmdd
- 11| -or 113 | dd Mon yyyy hh:mi:ss:mmm (24-hour system)
- 14 | 114 | Hh:mi:ss:mmm (24-hour system)
- 15 | or | yyyy-mm-dd hh:mi:ss (24-hour system)
- 16 | or 121 | Yyyy-mm-dd hh:mi:ss:mmm (24-hour system)
Specific examples:
- SELECT CONVERT (varchar), GETDATE (), 0): 2006 10:57am
- SELECT CONVERT (varchar), GETDATE (), 1): 05/16/06
- SELECT CONVERT (varchar), GETDATE (), 2): 06.05.16
- SELECT CONVERT (varchar), GETDATE (), 3): 16/05/06
- SELECT CONVERT (varchar), GETDATE (), 4): 16.05.06
- SELECT CONVERT (varchar), GETDATE (), 5): 16-05-06
- SELECT CONVERT (varchar), GETDATE (), 6):
- SELECT CONVERT (varchar), GETDATE (), 7):,
- SELECT CONVERT (varchar), GETDATE (), 8): 10:57:46
- SELECT CONVERT (varchar), GETDATE (), 9): 2006 10:57:46:827am
- SELECT CONVERT (varchar), GETDATE (), ten): 05-16-06
- SELECT CONVERT (varchar), GETDATE (), one): 06/05/16
- SELECT CONVERT (varchar), GETDATE (), (+): 060516
- SELECT CONVERT (varchar), GETDATE (): 2006 10:57:46:937
- SELECT CONVERT (varchar), GETDATE (), +): 10:57:46:967
- SELECT CONVERT (varchar), GETDATE (): 2006-05-16 10:57:47
- SELECT CONVERT (varchar), GETDATE (), (+): 2006-05-16 10:57:47.157
- SELECT CONVERT (varchar), GETDATE (): 05/16/06 10:57:47 AM
- SELECT CONVERT (varchar), GETDATE (), max): 2006-05-16
- SELECT CONVERT (varchar), GETDATE (): 10:57:47
- SELECT CONVERT (varchar), GETDATE (), (+): 2006-05-16 10:57:47.250
- SELECT CONVERT (varchar), GETDATE (), (+): 2006 10:57am
- SELECT CONVERT (varchar), GETDATE (), 101): 05/16/2006
- SELECT CONVERT (varchar), GETDATE (), 102): 2006.05.16
- SELECT CONVERT (varchar), GETDATE (), 103): 16/05/2006
- SELECT CONVERT (varchar), GETDATE (), 104): 16.05.2006
- SELECT CONVERT (varchar), GETDATE (), max.: 16-05-2006
- SELECT CONVERT (varchar), GETDATE (), 106): 2006
- SELECT CONVERT (varchar), GETDATE (), 107): 2006
- SELECT CONVERT (varchar), GETDATE (), 108): 10:57:49
- SELECT CONVERT (varchar), GETDATE (), 109): 2006 10:57:49:437am
- SELECT CONVERT (varchar), GETDATE (), (+): 05-16-2006
- SELECT CONVERT (varchar), GETDATE (), 111): 2006/05/16
- SELECT CONVERT (varchar), GETDATE (), 20060516):
- SELECT CONVERT (varchar), GETDATE (), 113): 2006 10:57:49:513
- SELECT CONVERT (varchar), GETDATE (), (): 10:57:49:547
- SELECT CONVERT (varchar), GETDATE (), (+): 2006-05-16 10:57:49
- SELECT CONVERT (varchar), GETDATE (), 121): 2006-05-16 10:57:49.700
- SELECT CONVERT (varchar), GETDATE (), 126): 2006-05-16t10:57:49.827
- SELECT CONVERT (varchar), GETDATE (), ():?????????? 1427 10:57:49:907am
- SELECT CONVERT (varchar), GETDATE (), 131): 18/04/1427 10:57:49:920am
Example: Select Billdate,getdate (), convert (nvarchar (+), billdate,120), convert (nvarchar (+), GETDATE (), +) from Bill
(go) database Get current time getdate ()