SQL命令中DateTime格式参考

发表于:2007-06-30来源:作者:点击数: 标签:
SQL 命令中DateTime格式大全 Code in C# : DateTime MyDate = DateTime.Now; sSQL = Insert Into Article (Title,CreatedDate) Values (@#New Title@#,@# + MyDate.Format( g, null ) + @#); 格式字符参考表: Format character Description Default return

SQL命令中DateTime格式大全

Code in C# :
DateTime MyDate = DateTime.Now;
sSQL = "Insert Into Article (Title,CreatedDate) Values (@#New Title@#,@#" + MyDate.Format( "g", null ) + "@#)";
格式字符参考表:

Format character

Description

Default return format

d

Short date pattern

MM/dd/yyyy

D

Long date pattern

dddd, MMMM dd, yyyy

f

Full (long date + short time)

dddd, MMMM dd, yyyy HH:mm

F

Full date time pattern (long date + long time)

dddd, MMMM dd, yyyy HH:mm:ss

g

General (short date + short time)

MM/dd/yyyy HH:mm

G

General (short date + long time)

MM/dd/yyyy HH:mm:ss

m,M

Month day pattern

MMMM dd

r,R

RFC1123 pattern

ddd, dd MMM yyyy HH@#:@#mm@#:@#ss@#GMT@#

s

Sortable date time pattern: conforms to ISO 8601

yyyy-MM-dd HH:mm:ss

t

Short time pattern

HH:mm

T

Long time pattern

HH:mm:ss

u

Similar to "s"but uses universal time instead of local time.

yyyy-MM-dd HH:mm:ss

U

Universal sortable date time pattern

dddd, MMMM dd, yyyy HH:mm:ss

Y,y

Year month pattern

MMMM, yyyy

原文转自:http://www.ltesting.net