SQLʱ¼äº¯ÊýÏêϸ˵Ã÷
1. µ±Ç°ÏµÍ³ÈÕÆÚ¡¢Ê±¼ä
select getdate()
2. dateadd ÔÚÏòÖ¸¶¨ÈÕÆÚ¼ÓÉÏÒ»¶Îʱ¼äµÄ»ù´¡ÉÏ£¬·µ»ØÐ嵀 datetime Öµ
ÀýÈ磺ÏòÈÕÆÚ¼ÓÉÏ2Ìì
select dateadd(day,2,'2004-10-15') --·µ»Ø£º2004-10-17 00:00:00.000
3. datediff ·µ»Ø¿çÁ½¸öÖ¸¶¨ÈÕÆÚµÄÈÕÆÚºÍʱ¼ä±ß½çÊý¡£
select datediff(day,'2004-09-01','2004-09-18') --·µ»Ø£º17
4. datepart ·µ»Ø´ú±íÖ¸¶¨ÈÕÆÚµÄÖ¸¶¨ÈÕÆÚ²¿·ÖµÄÕûÊý¡£
SELECT DATEPART(month, '2004-10-15') --·µ»Ø 10
5. datename ·µ»Ø´ú±íÖ¸¶¨ÈÕÆÚµÄÖ¸¶¨ÈÕÆÚ²¿·ÖµÄ×Ö·û´®
SELECT datename(weekday, '2004-10-15') --·µ»Ø£ºÐÇÆÚÎå
6. day(), month(),year() --¿ÉÒÔÓëdatepart¶ÔÕÕÒ»ÏÂ
select µ±Ç°ÈÕÆÚ=convert(varchar(10),getdate(),120)
,µ±Ç°Ê±¼ä=convert(varchar(8),getdate(),114)
select datename(dw,'2004-10-15')
select ±¾ÄêµÚ¶àÉÙÖÜ=datename(week,'2004-10-15')
,½ñÌìÊÇÖܼ¸=datename(weekday,'2004-10-15')
º¯Êý ²ÎÊý/¹¦ÄÜ
GetDate( ) ·µ»ØϵͳĿǰµÄÈÕÆÚÓëʱ¼ä
DateDiff (interval,date1,date2) ÒÔinterval Ö¸¶¨µÄ·½Ê½£¬·µ»Ødate2 Óëdate1Á½¸öÈÕÆÚÖ®¼äµÄ²îÖµ date2-date1
DateAdd (interval,number,date) ÒÔintervalÖ¸¶¨µÄ·½Ê½£¬¼ÓÉÏnumberÖ®ºóµÄÈÕÆÚ
DatePart (interval,date) ·µ»ØÈÕÆÚdateÖУ¬intervalÖ¸¶¨²¿·ÖËù¶ÔÓ¦µÄÕûÊýÖµ
DateName (interval,date) ·µ»ØÈÕÆÚdateÖУ¬intervalÖ¸¶¨²¿·ÖËù¶ÔÓ¦µÄ×Ö·û´®Ãû³Æ
²ÎÊý intervalµÄÉ趨ֵÈçÏ£º
Öµ Ëõ д£¨Sql Server£© Access ºÍ ASP ˵Ã÷
Year Yy yyyy Äê 1753 ~ 9999
Quarter Qq q ¼¾ 1 ~ 4
Month Mm m ÔÂ1 ~ 12
Day of year Dy y Ò»ÄêµÄÈÕÊý,Ò»ÄêÖеĵڼ¸ÈÕ 1-366
Day Dd d ÈÕ£¬1-31
Weekday Dw w Ò»ÖܵÄÈÕÊý£¬Ò»ÖÜÖеĵڼ¸ÈÕ 1-7
Week Wk ww ÖÜ£¬Ò»ÄêÖеĵڼ¸ÖÜ 0 ~ 51
Hour Hh h ʱ0 ~ 23
Minute Mi n ·ÖÖÓ0 ~ 59
Second Ss s Ãë 0 ~ 59
Millisecond Ms - ºÁÃë 0 ~ 999
access ºÍ asp ÖÐÓÃdate()ºÍnow()È¡µÃϵͳÈÕÆÚʱ¼ä£»ÆäÖÐDateDiff,DateAdd,DatePartҲͬÊÇÄÜÓÃÓÚAccessºÍaspÖУ¬ÕâЩº¯ÊýµÄÓ÷¨Ò²ÀàËÆ
¾ÙÀý£º
1.GetDate() ÓÃÓÚsql server :select GetDate()
2.DateDiff('s','2005-07-20','2005-7-25 22:56:32')·µ»ØֵΪ 514592 Ãë
DateDiff('d','2005-07-20','2005-7-25 22:56:32')·µ»ØֵΪ 5 Ìì
3.DatePart('w','2005-7-25 22:56:32')·µ»ØֵΪ 2 ¼´ÐÇÆÚÒ»(ÖÜÈÕΪ1£¬ÖÜÁùΪ7)
DatePart('d','2005-7-25 22:
Ïà¹ØÎĵµ£º
1¡¢½øÈëÆóÒµ¹ÜÀíÆ÷ÖÐ->¹ÜÀí->sql server´úÀí->×÷Òµ£»
¡¡¡¡2¡¢Ð½¨×÷Òµ£¬×÷ÒµÃû³ÆËæ±ãÈ¡£¬ÀýÈ磺data±¸·Ý£¬ËùÓÐÕßÑ¡Ôñsa£¬µ±È»ÄãÒ²¿ÉÒÔÑ¡ÔñÆäËûÓû§£¬Ç°ÌáÊǸÃÓû§ÓÐÖ´ÐÐ×÷ÒµµÄȨÏÞ£»
¡¡¡¡3¡¢µã»÷²½Öè±êÇ©£¬½øÈë²½ÖèÃæ°å¡£Ð½¨²½Ö裬²½ÖèÃû¿ÉÒÔËæ±ãÌîд£¬Èç²½Öè1£¬ÀàÐͺÍÊý¾Ý¿âĬÈÏ£¬²» ......
ÔÒò·ÖÎö:
SERVERPROPERTY º¯ÊýµÄ ServerName ÊôÐÔÓë@@SERVERNAME ·µ»ØÏàËƵÄÐÅÏ¢¡£ServerName ÊôÐÔÌṩWindows ·þÎñÆ÷ºÍʵÀýÃû³Æ£¬Á½Õß¹²Í¬¹¹³ÉΨһµÄ·þÎñÆ÷ʵÀý£»@@SERVERNAME Ìṩµ±Ç°ÅäÖõı¾µØ·þÎñÆ÷Ãû³Æ¡£
Èç¹û°²×°Ê±Î´¸ü¸ÄĬÈÏ·þÎñÆ÷Ãû³Æ£¬Ôò ServerName ÊôÐÔºÍ @@SERVERNAME ·µ»ØÏàͬµÄÐÅÏ¢¡£Èç¹ûÔÚ°²×°Ê±Òѽ«±¾µ ......
¿ª·ÅÐÔ ¡¡¡¡SQL Server
¡¡¡¡Ö»ÄÜÔÚWindows ÉÏÔËÐУ¬Ã»ÓÐË¿ºÁµÄ¿ª·ÅÐÔ£¬²Ù×÷ϵͳµÄϵͳµÄÎȶ¨¶ÔÊý¾Ý¿âÊÇÊ®·ÖÖØÒªµÄ¡£Windows9XϵÁвúÆ·ÊÇÆ«ÖØÓÚ×ÀÃæÓ¦Óã¬NT serverÖ»ÊʺÏÖÐСÐÍÆóÒµ¡£¶øÇÒWindowsƽ̨µÄ¿É¿¿ÐÔ£¬°²È«ÐÔºÍÉìËõÐÔÊǷdz£ÓÐÏ޵ġ£Ëü²»ÏóUnixÄÇÑù¾Ã¾¿¼Ñ飬ÓÈÆäÊÇÔÚ´¦Àí´óÊý¾ÝÁ¿µÄ¹Ø¼üÒµÎñʱ¡£
¡¡¡¡Oracle
......
½ñÌì¸Õ¿ªÍ¨Õâ¸öС²©£¬×÷ΪÇì×££¬°ÑÎÒÒÔÇ°¿Õ¼äÖеÄһƪÎÄÕÂת¹ýÀ´¡£
Ï£Íû¶Ô
ÎÊÌ⣺ÓÉÓÚ°²×°sql server 2000 sp4ÒÔºóÐÞ¸ÄÁË·þÎñÆ÷µÄÃû³Æµ¼ÖÂSQLÖб£ÁôµÄ·þÎñÆ÷Ãû²»ÕýÈ·¡£
½â¾ö·½·¨£º
1.select @@servername
²é¿´·µ»ØÖµÊÇ·ñÓëÏÖÔÚ»úÆ÷Ãû²»Ò»Ö£¨Èç¹ûÒ»Ö¾ÍÊDZðµÄÎÊÌâÁË£©
2.exec sp_helpserver
²é¿´Ó¦¸ÃÓÐNAMEÓënetwork ......
If the SQL data type is 'timestamp', we need to use ResultSet.getBytes() to retrieve its value. If the SQL data type is 'datetime', we can use ResultSet.getTimestamp(). It is said timestamp is interanlly saved as binary data.
try {
Class.forName("com.microsoft. ......