½¨Õ¾Ñ§ - ÇáËɽ¨Õ¾´Ó´Ë¿ªÊ¼£¡

½¨Õ¾Ñ§-¸öÈ˽¨Õ¾Ö¸ÄÏ,ÍøÒ³ÖÆ×÷,ÍøÕ¾Éè¼Æ,ÍøÕ¾ÖÆ×÷½Ì³Ì

µ±Ç°Î»ÖÃ: ½¨Õ¾Ñ§ > ÍøÕ¾¿ª·¢ > asp½Ì³Ì >

asp DateDiff ʱ¼äº¯ÊýµÄÓï·¨

ʱ¼ä:2009-02-25 17:39À´Ô´:ÍøÂç ×÷Õß: µã»÷: ´Î
interval ±ØÑ¡¡£String expression ±íʾÓÃÓÚ¼ÆËã date1 ºÍdate2 Ö®¼äµÄʱ¼ä¼ä¸ô¡£ÓйØÊýÖµ£¬Çë²ÎÔÄ¡°ÉèÖá±²¿·Ö¡£ date1, date2 ±ØÑ¡¡£ÈÕÆÚ±í´ïʽ¡£ÓÃÓÚ¼ÆËãµÄÁ½¸öÈÕÆÚ¡£ firstdayofweek ¿ÉÑ¡¡£Ö¸¶¨ÐÇÆÚÖеÚÒ»ÌìµÄ³£Êý¡£Èç¹ûûÓÐÖ¸¶¨£¬ÔòĬÈÏΪÐÇÆÚÈÕ¡£ÓйØÊýÖµ£¬Çë²ÎÔÄ
ÃèÊö
·µ»ØÁ½¸öÈÕÆÚÖ®¼äµÄʱ¼ä¼ä¸ô¡£
Óï·¨
DateDiff(interval, date1, date2 [,firstdayofweek[, firstweekofyear]])
DateDiff º¯ÊýµÄÓï·¨ÓÐÒÔϲÎÊý£º

²ÎÊý ÃèÊö
interval ±ØÑ¡¡£String expression ±íʾÓÃÓÚ¼ÆËã date1 ºÍ date2 Ö®¼äµÄʱ¼ä¼ä¸ô¡£ÓйØÊýÖµ£¬Çë²ÎÔÄ“ÉèÖÔ²¿·Ö¡£
date1, date2 ±ØÑ¡¡£ÈÕÆÚ±í´ïʽ¡£ÓÃÓÚ¼ÆËãµÄÁ½¸öÈÕÆÚ¡£
firstdayofweek ¿ÉÑ¡¡£Ö¸¶¨ÐÇÆÚÖеÚÒ»ÌìµÄ³£Êý¡£Èç¹ûûÓÐÖ¸¶¨£¬ÔòĬÈÏΪÐÇÆÚÈÕ¡£ÓйØÊýÖµ£¬Çë²ÎÔÄ“ÉèÖÔ²¿·Ö¡£
firstweekofyear ¿ÉÑ¡¡£Ö¸¶¨Ò»ÄêÖеÚÒ»Öܵij£Êý¡£Èç¹ûûÓÐÖ¸¶¨£¬ÔòĬÈÏΪ 1 Ô 1 ÈÕËùÔÚµÄÐÇÆÚ¡£ÓйØÊýÖµ£¬Çë²ÎÔÄ“ÉèÖÔ²¿·Ö¡£



ÉèÖÃ
interval ²ÎÊý¿ÉÒÔÓÐÒÔÏÂÖµ£º
ÉèÖà ÃèÊö
yyyy Äê
q ¼¾¶È
n ÔÂ
y Ò»ÄêµÄÈÕÊý
d ÈÕ
w Ò»ÖܵÄÈÕÊý
ww ÖÜ
h Сʱ
m ·ÖÖÓ
s Ãë


firstdayofweek ²ÎÊý¿ÉÒÔÓÐÒÔÏÂÖµ£º

³£Êý Öµ ÃèÊö
vbUseSystem 0 ʹÓÃÇøÓòÓïÑÔÖ§³Ö (NLS) API ÉèÖá£
vbSunday 1 ÐÇÆÚÈÕ£¨Ä¬ÈÏ£©
vbMonday 2 ÐÇÆÚÒ»
vbTuesday 3 ÐÇÆÚ¶þ
vbWednesday 4 ÐÇÆÚÈý
vbThursday 5 ÐÇÆÚËÄ
vbFriday 6 ÐÇÆÚÎå
vbSaturday 7 ÐÇÆÚÁù


firstweekofyear ²ÎÊý¿ÉÒÔÓÐÒÔÏÂÖµ£º

³£Êý Öµ ÃèÊö
vbUseSystem 0 ʹÓÃÇøÓòÓïÑÔÖ§³Ö (NLS) API ÉèÖá£
vbFirstJan1 1 ÓÉ 1 Ô 1 ÈÕËùÔÚµÄÐÇÆÚ¿ªÊ¼£¨Ä¬ÈÏ£©¡£
vbFirstFourDays 2 ÓÉÔÚÐÂÄêÖÐÖÁÉÙÓÐËÄÌìµÄµÚÒ»ÖÜ¿ªÊ¼¡£
vbFirstFullWeek 3 ÓÉÔÚеÄÒ»ÄêÖеÚÒ»¸öÍêÕûµÄÖÜ¿ªÊ¼¡£


˵Ã÷
DateDiff º¯ÊýÓÃÓÚÅжÏÔÚÁ½¸öÈÕÆÚÖ®¼ä´æÔÚµÄÖ¸¶¨Ê±¼ä¼ä¸ôµÄÊýÄ¿¡£ÀýÈç¿ÉÒÔʹÓà DateDiff ¼ÆËãÁ½¸öÈÕÆÚÏà²îµÄÌìÊý£¬»òÕßµ±Ììµ½µ±Äê×îºóÒ»ÌìÖ®¼äµÄÐÇÆÚÊý¡£
Òª¼ÆËã date1 ºÍ date2 Ïà²îµÄÌìÊý£¬¿ÉÒÔʹÓÓһÄêµÄÈÕÊý”£¨“y”£©»ò“ÈÕ”£¨“d”£©¡£µ± interval Ϊ“Ò»ÖܵÄÈÕÊý”£¨“w”£©Ê±£¬DateDiff ·µ»ØÁ½¸öÈÕÆÚÖ®¼äµÄÐÇÆÚÊý¡£Èç¹û date1 ÊÇÐÇÆÚÒ»£¬Ôò DateDiff ¼ÆËãµ½ date2 ֮ǰÐÇÆÚÒ»µÄÊýÄ¿¡£´Ë½á¹û°üº¬ date2 ¶ø²»°üº¬ date1¡£Èç¹û interval ÊÇ“ÖÜ”£¨“ww”£©£¬Ôò DateDiff º¯Êý·µ»ØÈÕÀú±íÖÐÁ½¸öÈÕÆÚÖ®¼äµÄÐÇÆÚÊý¡£º¯Êý¼ÆËã date1 ºÍ date2 Ö®¼äÐÇÆÚÈÕµÄÊýÄ¿¡£Èç¹û date2 ÊÇÐÇÆÚÈÕ£¬DateDiff ½«¼ÆËã date2£¬µ«¼´Ê¹ date1 ÊÇÐÇÆÚÈÕ£¬Ò²²»»á¼ÆËã date1¡£

Èç¹û date1 ÍíÓÚ date2£¬Ôò DateDiff º¯Êý·µ»Ø¸ºÊý¡£

firstdayofweek ²ÎÊý»á¶ÔʹÓÓw”ºÍ“ww”¼ä¸ô·ûºÅµÄ¼ÆËã²úÉúÓ°Ïì¡£

Èç¹û date1 »ò date2 ÊÇÈÕÆÚÎÄ×Ö£¬ÔòÖ¸¶¨µÄÄê¶È»á³ÉΪÈÕÆڵĹ̶¨²¿·Ö¡£µ«ÊÇÈç¹û date1 »ò date2 ±»°üÀ¨ÔÚÒýºÅ (" ") Öв¢ÇÒÊ¡ÂÔÄê·Ý£¬ÔòÔÚ´úÂëÖÐÿ´Î¼ÆËã date1 »ò date2 ±í´ïʽʱ£¬½«²åÈ뵱ǰÄê·Ý¡£ÕâÑù¾Í¿ÉÒÔ±àдÊÊÓÃÓÚ²»Í¬Äê·ÝµÄ³ÌÐò´úÂë¡£

ÔÚ interval Ϊ“Äꔣ¨“yyyy”£©Ê±£¬±È½Ï 12 Ô 31 ÈÕºÍÀ´ÄêµÄ 1 Ô 1 ÈÕ£¬ËäȻʵ¼ÊÉÏÖ»Ïà²îÒ»Ì죬DateDiff ·µ»Ø 1 ±íʾÏà²îÒ»¸öÄê·Ý¡£

ÏÂÃæµÄʾÀýÀûÓà DateDiff º¯ÊýÏÔʾ½ñÌìÓë¸ø¶¨ÈÕÆÚÖ®¼ä¼ä¸ôÌìÊý:

Function DiffADate(theDate)
DiffADate = "´Óµ±Ì쿪ʼµÄÌìÊý:" & DateDiff("d", Now, theDate)
End Function
(ÔðÈα༭£ºadmin)
Ö¯ÃζþάÂëÉú³ÉÆ÷
¶¥Ò»ÏÂ
(0)
0%
²ÈÒ»ÏÂ
(0)
0%
------·Ö¸ôÏß----------------------------
·¢±íÆÀÂÛ
Çë×Ô¾õ×ñÊØ»¥ÁªÍøÏà¹ØµÄÕþ²ß·¨¹æ£¬ÑϽû·¢²¼É«Çé¡¢±©Á¦¡¢·´¶¯µÄÑÔÂÛ¡£
ÆÀ¼Û:
񡀂:
Óû§Ãû: ÑéÖ¤Âë:µã»÷ÎÒ¸ü»»Í¼Æ¬