Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

SQLServerÖÐDatetimeÀàÐÍÊý¾ÝµÄ±È½Ï

SQLServerÖÐDatetimeÀàÐÍÊý¾ÝµÄ±È½Ï
2009Äê02ÔÂ20ÈÕ ÐÇÆÚÎå 16:40
 
 
/* ¶¨Ò忪ʼÈÕÆÚºÍ½áÊøÈÕÆÚ*/
declare @date_a datetime,@date_b datetime
set @date_a='2009-2-10'
set @date_b='2009-2-12'
/* ÔÚÈÕÆÚdate_a(°üº¬) ºÍdate_b(²»°üº¬) Ö®¼ä*/
select * from ut_article where createtime between @date_a and @date_b
/* ÔÚÈÕÆÚdate_a(²»°üº¬) ºÍdate_b(°üº¬) Ö®¼ä*/
select * from ut_article where datediff(d,@date_a,createtime)>0 and datediff(d,@date_b,createtime)<=0
/* ÔÚÈÕÆÚdate_a(²»°üº¬) ºÍdate_b(²»°üº¬) Ö®¼ä*/
select * from ut_article where datediff(d,@date_a,createtime)>0 and datediff(d,@date_b,createtime)<0
/* ÔÚÈÕÆÚdate_a(°üº¬) ºÍdate_b(°üº¬) Ö®¼ä*/
select * from ut_article where datediff(d,@date_a,createtime)>=0 and datediff(d,@date_b,createtime)<=0


Ïà¹ØÎĵµ£º

SpringÅäÖõÄMS SQLSERVER 2008 JDBCÁ¬½Ó


  ²»µÃ²»ËµµÄÔÚ MS SQL SERVER Ï嵀 JDBC µ÷ÓÃ
 
½ñÌìÏÂÎ磬ÁÙʱ¾ö¶¨ÒªÔÙ MS SQL-SERVER  ÏÂÅäÖà Spring µÄÊý¾ÝÔ´ DataSource ¡£µ«ÅäÖÃÁ˰ëÌì,»ñÈ¡Êý¾ÝÔ´ÈÔ²»³É¹¦£¬ÎÒûÓа취£¬ÕÒÔ­Òòߣ¬Ö»ÄÜд¸öÁÐ×Ó²âÊÔÏ¡£ÏȲ»¹ÜÈýÆß¶þʮһ£¬ÏÈÉÏÕýÈ·µÄÀý×ÓÔÙ˵¡£
¿´¿ÍÈç¹ûÏëÔËÐÐÏÂÃæµÄ´úÂ룬ÐèÒª×Ô¼ºÊÖ¹¤ ......

sqlserver dateadd

-- ÔÚÏòÖ¸¶¨ÈÕÆÚ¼ÓÉÏÒ»¶Îʱ¼äµÄ»ù´¡ÉÏ£¬·µ»ØÐ嵀 datetime Öµ
¼ÓÄê·Ý——print dateadd(year, 5, getdate())       ¼ÓÔ·ݗ—print dateadd(month, 5, getdate())
¼ÓÌìÊý——print dateadd(day, 5, getdate())    ¼ÓСʱ——print dat ......

SQLSERVERÍâÁ¬½Ó·û

±íA
tmpA:
id     name
00     Ãû×ÖA
01     Ãû×ÖB
02     Ãû×ÖC
03     Ãû×ÖD
04     Ãû×ÖE
tmpB:
id     class
02     °à¼¶A
06 & ......

SQLServerÖÐÓõıȽ϶àµÄº¯Êý

ÏÂÃæÊÇÎÒÔÚSQLServerÖÐÓõıȽ϶àµÄº¯Êý£¬Ä㻹ÓÃЩʲôº¯Êý£¿»òÕß¶ÔÄĸöº¯ÊýÓбȽϺÃÓ÷¨£¿»òÕßÄã²»ÓÃÄÄЩº¯Êý£¿
LEFT ( character_expression , integer_expression )
·µ»Ø´Ó×Ö·û´®×ó±ß¿ªÊ¼Ö¸¶¨¸öÊýµÄ×Ö·û¡£
Àý:
select left('my name is viwo',4)
my n
RIGHT ( character_expression , integer_expression )
·µ» ......

SqlServerÖÐÐбäÁÐ

     ÀýÈç´´½¨Ò»¸ö±í
                 create table stz
              (
          &n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ