SQL命令中DateTime格式大全
</td></tr></table><table class=ubb cellspacing=0><tr><td class=ubb>
Code in C# :<font color=#FF0000>
DateTime MyDate = DateTime.Now;
sSQL = "Insert Into Article (Title,CreatedDate) Values (‘New Title‘,‘" MyDate.Format( "g", null ) "‘)";</font>
格式字符参考表:
<table class=ubb cellspacing=0><tr><td class=ubb>
<b>Format character</b></td><td class=ubb><b>
Description</b></td><td class=ubb><b>
Default return format</b></td></tr><tr><td class=ubb>
d</td><td class=ubb>
Short date pattern</td><td class=ubb>
MM/dd/yyyy</td></tr><tr><td class=ubb>
D</td><td class=ubb>
Long date pattern</td><td class=ubb>
dddd, MMMM dd, yyyy</td></tr><tr><td class=ubb>
f</td><td class=ubb>
Full (long date short time)</td><td class=ubb>
dddd, MMMM dd, yyyy HH:mm</td></tr><tr><td class=ubb>
F</td><td class=ubb>
Full date time pattern (long date long time)</td><td class=ubb>
dddd, MMMM dd, yyyy HH:mm:ss</td></tr><tr><td class=ubb>
g</td><td class=ubb>
General (short date short time)</td><td class=ubb>
MM/dd/yyyy HH:mm</td></tr><tr><td class=ubb>
G</td><td class=ubb>
General (short date long time)</td><td class=ubb>
MM/dd/yyyy HH:mm:ss</td></tr><tr><td class=ubb>
m,M</td><td class=ubb>
Month day pattern</td><td class=ubb>
MMMM dd</td></tr><tr><td class=ubb>
r,R</td><td class=ubb>
RFC1123 pattern </td><td class=ubb>
ddd, dd MMM yyyy HH‘:‘mm‘:‘ss‘GMT‘</td></tr><tr><td class=ubb>
s</td><td class=ubb>
Sortable date time pattern: conforms to ISO 8601</td><td class=ubb>
yyyy-MM-dd HH:mm:ss</td></tr><tr><td class=ubb>
t</td><td class=ubb>
Short time pattern</td><td class=ubb>
HH:mm</td></tr><tr><td class=ubb>
T</td><td class=ubb>
Long time pattern</td><td class=ubb>
HH:mm:ss</td></tr><tr><td class=ubb>
u</td><td class=ubb>
Similar to "s"but uses universal time instead of local time.</td><td class=ubb>
yyyy-MM-dd HH:mm:ss</td></tr><tr><td class=ubb>
U</td><td class=ubb>
Universal sortable date time pattern</td><td class=ubb>
dddd, MMMM dd, yyyy HH:mm:ss</td></tr><tr><td class=ubb>
Y,y</td><td class=ubb>
Year month pattern</td><td class=ubb>
MMMM, yyyy</td></tr></table></td></tr></table>