首页 > 开发 > 综合 > 正文

SQL命令中DateTime格式参考

2024-07-21 02:25:14
字体:
来源:转载
供稿:网友

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
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表