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

SQL DateTime²éѯÓë¸ñʽ

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 Óï¾äʹÓÃ

SQLÓï¾ä(Ôö¡¢É¾¡¢¸Ä¡¢²é)
¡¡¡¡
¡¡¡¡Ò»¡¢Ôö£ºÓÐ4ÖÖ·½·¨
¡¡¡¡
¡¡¡¡1.ʹÓÃinsert²åÈëµ¥ÐÐÊý¾Ý£º
¡¡¡¡
¡¡¡¡Óï·¨£ºinsert [into] <±íÃû> [ÁÐÃû] values <ÁÐÖµ>
¡¡¡¡
¡¡¡¡Àý£ºinsert into Strdents (ÐÕÃû,ÐÔ±ð,³öÉúÈÕÆÚ) values ('¿ªÐÄÅóÅó','ÄÐ','1980/6/15')
¡¡¡¡
¡¡¡¡×¢Ò⣺into¿ÉÒÔÊ¡ÂÔ£»ÁÐÃûÁÐÖµÓöºº ......

SQL SERVERÏÂͼƬµÄ²åÈëÓë¶ÁÈ¡

ÏÂÎçÏòÊý¾Ý¿âSQL SERVERÖÐÓöµ½Ìí¼ÓͼƬÀàÐÍÊý¾ÝµÄÎÊÌ⣬±¾ÒÔΪÔÚ½çÃæ¹ÜÀíÆ÷ÖпÉÒÔÖ±½Ó£¨Í¨¹ýÖ¸¶¨Â·¾¶°ÑͼƬµÄÊý¾Ý±£´æÆðÀ´£©Ìí¼ÓͼƬȴ²»È»¡£ÍøÉÏËÑÁËÏÂÕÒµ½ÁËÏà¹ØµÄ½ÏרҵµÄ×ÊÁÏ£¬ÕûºÏ½â¶Áһϣº Á½ÖÖ·½·¨£º       µÚÒ»¾ÍÊÇÔÚÊý¾Ý¿âÖд洢ͼƬµÄ·¾¶£¬È»ºóÔÚ³ÌÐòÖиù¾Ý¶ÁÈ¡µÄ·¾¶¶ÁȡͼƬ£»ÕâÖ ......

sql¡¡ÅÅÐò¹æÔò

µÚÒ»ÖÖ°ì·¨£ºÏÈÑ¡Öгö´íµÄÊý¾Ý¿â→Ñ¡ÖÐÒÔºóÓÒ¼üµã»÷ÊôÐԻᵯ³öÊý¾Ý¿âÊôÐÔ ¶Ô»°¿ò→Ñ¡ÖÐÊý¾Ý¿âÊôÐÔ¶Ô»°¿òÖеÄÑ¡Ïî→°ÑÑ¡ÏîÖеÄÅÅÐò¹æÔòÉèÖóÉ:Chinese_PRC_90_CI_AS→×îºóµã»÷È·¶¨¼´¿É¡£
£¨×¢Ò⣺ÔÚÑ¡ÔñÊý¾Ý¿âÊôÐÔµÄʱºò±ØÐëÈ·±£ÄãËùÐ޸ĵÄÊý¾Ý¿âδ±»Ê¹ÓòſÉÒÔÐ޸ķñÔò»áʧ°ÜµÄ£©
µÚ¶þÖÖ°ì·¨£ºÊ×ÏÈ´ò¿ªÄã ......

sqlʱ¼ä±È½Ï²Ù×÷³£Óú¯Êý

--ÈÕÆÚת»»²ÎÊý,ÖµµÃÊÕ²Ø
select CONVERT(varchar, getdate(), 120)
2004-09-12 11:06:08
select convert(varchar(10),getdate() ,120) 
----------
2009-04-09
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')
20040912110608
select CONVERT(varchar(12) , get ......

Oracle PL/SQLÖÐÈçºÎʹÓÃ%TYPEºÍ%ROWTYPE

¡¡
¡¡¡¡1. ʹÓÃ%TYPE
¡¡¡¡ÔÚÐí¶àÇé¿öÏ£¬PL/SQL±äÁ¿¿ÉÒÔÓÃÀ´´æ´¢ÔÚÊý¾Ý¿â±íÖеÄÊý¾Ý¡£ÔÚÕâÖÖÇé¿öÏ£¬±äÁ¿Ó¦¸ÃÓµÓÐÓë±íÁÐÏàͬµÄÀàÐÍ¡£ÀýÈ磬students±íµÄfirst_nameÁеÄÀàÐÍΪVARCHAR2(20),ÎÒÃÇ¿ÉÒÔ°´ÕÕÏÂÊö·½Ê½ÉùÃ÷Ò»¸ö±äÁ¿£º
¡¡¡¡DECLARE
¡¡¡¡ v_FirstName VARCHAR2(20);
¡¡
¡¡µ«ÊÇÈç¹ûfirst_nameÁеĶ¨Òå¸Ä±äÁ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ