select * from orders where month(orderdate)= (select month(orderdate) from orders where orderid=10248)
1.Ò»¸öÔµÚÒ»ÌìµÄ
Select DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)
2.±¾ÖܵÄÐÇÆÚÒ»
Select DATEADD(wk, DATEDIFF(wk,0,getdate()), 0)
3.Ò»ÄêµÄµÚÒ»Ìì
Select DATEADD(yy, DATEDIFF(yy,0,getdate()), 0)
4.¼¾¶ÈµÄµÚÒ»Ìì
Select DATEADD(qq, DATEDIFF(qq,0,getdate()), 0)
5.µ±ÌìµÄ°ëÒ¹
Select DATEADD(dd, DATEDIFF(dd,0,getdate()), 0)
6.ÉϸöÔµÄ×îºóÒ»Ìì
Select dateadd(ms,-3,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0))
7.È¥ÄêµÄ×îºóÒ»Ìì
Select dateadd(ms,-3,DATEADD(yy, DATEDIFF(yy,0,getdate()), 0))
8.±¾ÔµÄ×îºóÒ»Ìì
Select dateadd(ms,-3,DATEADD(mm, DATEDIFF(m,0,getdate())+1, 0))
9.±¾ÄêµÄ×îºóÒ»Ìì
Select dateadd(ms,-3,DATEADD(yy, DATEDIFF(yy,0,getdate())+1, 0))
10.±¾ÔµĵÚÒ»¸öÐÇÆÚÒ»
select DATEADD(wk, DATEDIFF(wk,0,dateadd(dd,6-datepart(day,getdate()),getdate())), 0)
·µ»Øµ±Ç°ÈÕÆÚºÍʱ¼ä
ͨ¹ýº¯ÊýGETDATE£¨£©£¬Äã¿ÉÒÔ»ñµÃµ±Ç°µÄÈÕÆÚºÍʱ¼ä¡£º¯ÊýGETDATE£¨£©¿ÉÒÔÓÃÀ´×÷ΪDATEDIMEÐÍ×ֶεÄȱʡֵ¡£Õâ¶Ô²åÈë¼Ç¼ʱ±£´æµ±Ê±µÄʱ¼äÊÇÓÐÓõġ£Òª½¨Á¢Ò»¸ö±í£¬ÆäÖеļǼ°üº¬Óе±Ç°µÄÈÕÆÚºÍʱ¼ä£¬¿ÉÒÔÌí¼ÓÒ»¸öDATETIMEÐÍ×ֶΣ¬Ö¸¶¨ÆäȱʡֵΪº¯ÊýGETDATE£¨£©µÄ·µ»ØÖµ£¬¾ÍÏóÕâÑù£º
Create TABLE site_log (
username VARCHAR(40)£¬
useractivity VARCHAR(100)£¬
entrydate DATETIME DEFAULT GETDATE())
ת»»ÈÕÆÚºÍʱ¼ä
º¯ÊýGETDATE£¨£©µÄ·µ»ØÖµÔÚÏÔʾʱֻÏÔʾµ½Ã롣ʵ¼ÊÉÏ£¬SQL SeverÄÚ²¿Ê±¼ä¿ÉÒÔ¾«È·µ½ºÁÃ뼶£¨È·ÇеØ˵£¬¿ÉÒÔ¾«È·µ½3.33ºÁÃ룩¡£
ÒªµÃµ½²»Í¬¸ñʽµÄÈÕÆÚºÍʱ¼ä£¬ÄãÐèҪʹÓú¯ÊýCONVERT£¨£©¡£ÀýÈ磬µ±ÏÂÃæµÄÕâ¸öÓï¾äÖ´ÐÐʱ£¬ÏÔʾµÄʱ¼ä½«°üÀ¨ºÁÃ룺
Select CONVERT(VARCHAR(30)£¬GETDATE()£¬9)
×¢ÒâÀý×ÓÖÐÊý×Ö9µÄʹÓá£Õâ¸öÊý×ÖÖ¸Ã÷ÁËÔÚÏÔʾÈÕÆÚºÍʱ¼äʱʹÓÃÄÄÖÖÈÕÆÚºÍʱ¼ä¸ñʽ¡£µ±Õâ¸öÓï¾äÖ´ÐÐʱ£¬½«ÏÔʾÈçϵÄÈÕÆÚºÍʱ¼ä£º
Nov 30 1997 3:29:55:170AM
(1 row(s) affected)
ÔÚº¯ÊýCONVERT£¨£©ÖÐÄã¿ÉÒÔʹÓÃÐí¶àÖÖ²»Í¬·ç¸ñµÄÈÕÆÚºÍʱ¼ä¸ñʽ¡£Ï±íÏÔʾÁËËùÓеĸñʽ¡£
ÈÕÆÚºÍʱ¼äµÄÀàÐÍ£º
ÀàÐÍÖµ ±ê×¼ Êä³ö
0 Default mon dd yyyy hh:miAM
1 USA mm/dd/yy
2 ANSI yy.mm.dd
3 British/French dd/mm/yy
4 German dd.mm.yy
5 Italian dd-mm-yy
6 - dd mon yy
×î½üÁ½ÌìÒ»Ö±ÔÚÕÛÌÚSQLÓï¾ä£¬Ã»°ì·¨£¬Ð´Êý¾Ý¿âµÄÐֵܸøÁËÁ½¸öÀý×ӾͲ»ÔÙ¹ÜÁË£¬¶øÇÒ×î½üÇë¼ÙÁË¡£½ñÌì¼Ó°à»¹ÊÇÕÛÌÚÕâôһ¸öÓï¾ä£¬×ÜÊDz»¶Ô£¬ÇëÀÏ´ó¿´ÁË¿´»¹ÊÇû¿´³öÃŵÀÀ´£¬ ÔÚSQLite Expert Professional ÀïÃæдµÄÓï¾ä¶¼¿ÉÒÔÖ´Ðгɹ¦£¬µ«ÊÇÔÚAndroidµÄ¹¤³ÌÀïÃæÔõôÕÛÌھͲ»¶Ô¡£ ÓôÃÆ°¡£¬½ñÌì¼Ó°àËãÊÇ°×¼ÓÁË¡£
ΪÁ˲éÕÒºÍÑ§Ï ......
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'CLR', 0
GO
-- To update the currently configured value for this feature.
......
¡¡¡¡±¾ÎÄÌÖÂÛSQL Server 2005µÄй¦ÄÜ£¬ËüÔÊÐíÄ㽫XMLÊý¾Ý·Ö½âµ½¹Øϵ¸ñʽÖУ¬¶ø²»±ØºÄÓÃÌ«¶àÄÚ´æ¡£
¡¡¡¡±¾ÎÄÌÖÂÛSQL Server 2005µÄй¦ÄÜ£¬ËüÔÊÐíÄ㽫XMLÊý¾Ý·Ö½âµ½¹Øϵ¸ñʽÖУ¬¶ø²»±ØºÄÓÃÌ«¶àÄÚ´æ¡£
¡¡¡¡ÔÚ¾ÙÀý˵Ã÷ÈçºÎ·Ö½âÉÏһƪÎÄÕÂÖеÄÊý¾Ýʱ£¬ÎÒÃÇÊ×ÏÈÁ˽âÒ»ÏÂXQueryºÍËüÔÚSQL Server 2005ÖÐΪ¿ª·¢ÕßÌṩµÄ¹¦ÄÜ¡£
¡ ......