这是t -sql 的帮助,你看一下吧: 用 set dateformat 就可以确定sql 的日期输出格式。Sets the order of the dateparts (month/day/year) for entering datetime or smalldatetime data. SyntaxSET DATEFORMAT {format | @format_var}Argumentsformat | @format_varIs the order of the dateparts. Can be either Unicode or DBCS converted to Unicode. Valid parameters include mdy, dmy, ymd, ydm, myd, and dym. The U.S. English default is mdy.ResThis setting is used only in the interpretation of character strings as they are converted to date values. It has no effect on the display of date values. The setting of SET DATEFORMAT is set at execute or run time and not at parse time.PermissionsSET DATEFORMAT permissions default to all users.ExamplesThis example uses different date formats to handle date strings in different formats.SET DATEFORMAT mdyGODECLARE @datevar datetimeSET @datevar = '12/31/98'SELECT @datevarGO SET DATEFORMAT ydmGODECLARE @datevar datetimeSET @datevar = '98/31/12'SELECT @datevarGO SET DATEFORMAT ymdGODECLARE @datevar datetimeSET @datevar = '98/12/31'SELECT @datevarGO
0 或 100 (*) 默认值 mon dd yyyy hh:miAM(或 PM)
1 101 美国 mm/dd/yyyy
2 102 ANSI 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 或 109 (*) 默认值 + 毫秒 mon dd yyyy hh:mi:ss:mmmAM(或 PM)
10 110 美国 mm-dd-yy
11 111 日本 yy/mm/dd
12 112 ISO yymmdd
- 13 或 113 (*) 欧洲默认值 + 毫秒 dd mon yyyy hh:mm:ss:mmm(24h)
14 114 - hh:mi:ss:mmm(24h)
- 20 或 120 (*) ODBC 规范 yyyy-mm-dd hh:mm:ss[.fff]
- 21 或 121 (*) ODBC 规范(带毫秒) yyyy-mm-dd hh:mm:ss[.fff]
- 126(***) ISO8601 yyyy-mm-dd Thh:mm:ss:mmm(不含空格)
- 130* 科威特 dd mon yyyy hh:mi:ss:mmmAM
- 131* 科威特 dd/mm/yy hh:mi:ss:mmmAM
Cast(变量 AS 类型) ;
祝你好运!!
用 set dateformat 就可以确定sql 的日期输出格式。Sets the order of the dateparts (month/day/year) for entering datetime or smalldatetime data.
SyntaxSET DATEFORMAT {format | @format_var}Argumentsformat | @format_varIs the order of the dateparts. Can be either Unicode or DBCS converted to Unicode. Valid parameters include mdy, dmy, ymd, ydm, myd, and dym. The U.S. English default is mdy.ResThis setting is used only in the interpretation of character strings as they are converted to date values. It has no effect on the display of date values.
The setting of SET DATEFORMAT is set at execute or run time and not at parse time.PermissionsSET DATEFORMAT permissions default to all users.ExamplesThis example uses different date formats to handle date strings in different formats.SET DATEFORMAT mdyGODECLARE @datevar datetimeSET @datevar = '12/31/98'SELECT @datevarGO SET DATEFORMAT ydmGODECLARE @datevar datetimeSET @datevar = '98/31/12'SELECT @datevarGO SET DATEFORMAT ymdGODECLARE @datevar datetimeSET @datevar = '98/12/31'SELECT @datevarGO