sql server 2000 ÈÕÆÚº¯Êý£¨Áª»ú°ïÖú£©
1.DATEADDº¯Êý
ÔÚÏòÖ¸¶¨ÈÕÆÚ¼ÓÉÏÒ»¶Îʱ¼äµÄ»ù´¡ÉÏ£¬·µ»ØÐ嵀 datetime Öµ¡£
Óï·¨
DATEADD ( datepart , number, date )
²ÎÊý
datepart
ÈÕÆÚ²¿·Ö
Ëõд
Year
yy, yyyy
quarter
qq, q
Month
mm, m
dayofyear
dy, y
Day
dd, d
Week
wk, ww
Hour
hh
minute
mi, n
second
ss, s
millisecond
ms
2. DATEDIFFº¯Êý
·µ»Ø¿çÁ½¸öÖ¸¶¨ÈÕÆÚµÄÈÕÆÚºÍʱ¼ä±ß½çÊý
²ÎÊý
datepart
Êǹ涨ÁËÓ¦ÔÚÈÕÆÚµÄÄÄÒ»²¿·Ö¼ÆËã²î¶îµÄ²ÎÊý¡£
ͬÉÏ
²âÊÔÊý¾Ý£º
if object_id('mma') is not null drop table mma
go
create table mma(mydate datetime)
go
insert into mma
select '20090203' union all
select '20090205' union all
select '20090209' union all
select '20091231' union all
select '20100102' union all
select '20100112' union all
select '20100116'
--²éѯ·µ»Ø±¾ÔµļǼ
·½·¨Ò»
select mydate from mma where datediff(m,mydate,getdate())=0(×¢µ±Ç°ÈÕÆÚÊÇ20100116)
·½·¨¶þ
SELECT * from mma WHERE CONVERT(CHAR(6), mydate,112)=CONVERT(CHAR(6),GETDATE(),112)
·½·¨Èý
select mydate from aa where substring(convert(varchar(20),getdate(),120),0,8)=substring(convert(varchar(20),mydate,120),0,8)
Ïà¹ØÎĵµ£º
ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......
µÚ1ÖÖ·½·¨£º
ÆóÒµ¹ÜÀíÆ÷
--¹ÜÀí
--ÓÒ¼üÊý¾Ý¿âά»¤¼Æ»®
--н¨Î¬»¤¼Æ»®
--<ÏÂÒ»²½>
--Ñ¡ÔñÄãÒª±¸·ÝµÄÊý¾Ý¿â
--<ÏÂÒ»²½>Ö±µ½"Ö¸¶¨Êý¾Ý¿â±¸·Ý¼Æ»®"ÕâÏî
--Ö¸¶¨´æ´¢±¸·ÝÎļþµÄλÖÃ,ÕâÀï¸ù¾ÝÐèҪѡÔñ±¸·Öµ½´Å´ø»¹ÊÇ´ÅÅÌ
--µ¥»÷µ÷¶ÈºóÃæµÄ"¸ü¸Ä"°´ ......
Èë Êƪ
Èç¹ûÄãÒÔǰûÊÔ¹ýSQL×¢ÈëµÄ»°£¬ÄÇôµÚÒ»²½ÏÈ°ÑIE²Ëµ¥=>¹¤¾ß=>InternetÑ¡Ïî=>¸ß¼¶=>ÏÔʾÓѺà HTTP ´íÎóÐÅϢǰÃæµÄ¹´È¥µô¡£·ñÔò£¬²»ÂÛ·þÎñÆ÷·µ»Øʲô´íÎó£¬IE¶¼Ö»ÏÔʾΪHTTP 500·þÎñÆ÷´íÎ󣬲»ÄÜ»ñµÃ¸ü¶àµÄÌáʾÐÅÏ¢¡£
µÚÒ»½Ú¡¢SQL×¢ÈëÔÀí
ÒÔÏÂÎÒÃÇ´ÓÒ»¸öÍøÕ¾www.19cn.com¿ªÊ¼£¨×¢£º±¾ÎÄ·¢±íÇ°ÒÑÕ÷µ ......
À´×Ô:http://www.cnblogs.com/mikeye/archive/2007/04/13/711878.html
ºÍÀ´×Ô:http://tech.ccidnet.com/art/3539/20080225/1370107_1.html
ÓÃeclipseÀ´½øÐÐMicrosoft SQL Server 2005Êý¾Ý¿â·½ÃæµÄ¿ª·¢£¬ÏÈ°ÑMS SQL Server 2005 JDBC DriverµÄÇý¶¯ÏÂÔغó¼ÓÈ빤³ÌÎļþµÄÀà¿âÖУ»È»ºóдURL×Ö·û´®¡£¸ù¾ÝÒÔÍùµÄд·¨Ð´È룺url = ......