--»ùÓÚʱ¼äSQLº¯Êý--
getdate() --·µ»Øµ±Ç°ÏµÍ³ÈÕÆÚºÍʱ¼ä¡£
DateAdd --ÔÚÏòÖ¸¶¨ÈÕÆÚ¼ÓÉÏÒ»¶Îʱ¼äµÄ»ù´¡ÉÏ£¬·µ»ØÐ嵀 datetime Öµ¡£
DATEADD ( datepart , number, date )
--Àý£ºÏòµ±ÌìµÄʱ¼äÔö¼Ó5Ìì
select dateadd(dd,5,getdate())
datediff --·µ»Ø¿çÁ½¸öÖ¸¶¨ÈÕÆÚµÄÈÕÆÚºÍʱ¼ä±ß½çÊý¡£]
---ÀýÈç
select datediff(day, '2009-08-08', getdate())
DATEDIFF ( datepart , startdate , enddate )
--°Ñʱ¼ä×ֶεÄÊý¾Ý±äΪÄêÔÂ
Select Convert(Varchar(6),GetDate(),112)
--×Ö·û´®±äʱ¼ä
select convert(datetime,left(@t,len(@t)-4)+':'+left(right(@t,4),2)+':'+right(@t,2))
ISDATE --È·¶¨ÊäÈë±í´ïʽÊÇ·ñΪÓÐЧµÄÈÕÆÚ
DATEPART --·µ»Ø´ú±íÖ¸¶¨ÈÕÆÚµÄÖ¸¶¨ÈÕÆÚ²¿·ÖµÄÕûÊý
DATEPART ( datepart , date )
--È磺·µ»Øµ±Ç°ÊǼ¸ÔÂ
select datepart(mm,getdate())
DATENAME --·µ»Ø´ú±íÖ¸¶¨ÈÕÆÚµÄÖ¸¶¨ÈÕÆÚ²¿·ÖµÄ×Ö·û´®
--datepart ,datenameµÄÇø±ð£ºÇ°Õß·µ»ØÊÇÕûÊý£¬ºóÕß·µ»ØÊÇ×Ö·û´®¡£
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
1.GetDate() ÓÃÓÚsql server :select GetDate()
2.DateDiff('s','2
ÏÖÒªÇó²éѯ½çÃ棺²»ÂÛ15λ»òÕß18λÉí·ÝÖ¤ºÅ¶¼Äܲéѯ³öÊý¾Ý¿âÖÐËùÓе±Ç°Óû§ÐÅÏ¢¡£
·½°¸1£º
create or replace function CONVERT_ID_15 (/*ת»»Éí·ÝÖ¤ºÅΪ15λ*/
p_id2 in varchar2
) return varchar2
is
p_id varchar2(20);
id varchar2(15);
begin
p_id:=ltrim(p_id2);
p_id ......