您的位置:建站学院首页 >> 文章 >> asp.net >> 数据库应用
SQL命令中DateTime格式参考
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
Google
 
Web www.cqxw.net