SQL ÈÕÆÚ
MySQL Date º¯Êý
ÏÂÃæµÄ±í¸ñÁгöÁË MySQL ÖÐ×îÖØÒªµÄÄÚ½¨ÈÕÆÚº¯Êý£º
º¯ÊýÃèÊö
NOW()
·µ»Øµ±Ç°µÄÈÕÆÚºÍʱ¼ä
CURDATE()
·µ»Øµ±Ç°µÄÈÕÆÚ
CURTIME()
·µ»Øµ±Ç°µÄʱ¼ä
DATE()
ÌáÈ¡ÈÕÆÚ»òÈÕÆÚ/ʱ¼ä±í´ïʽµÄÈÕÆÚ²¿·Ö
EXTRACT()
·µ»ØÈÕÆÚ/ʱ¼ä°´µÄµ¥¶À²¿·Ö
DATE_ADD()
¸øÈÕÆÚÌí¼ÓÖ¸¶¨µÄʱ¼ä¼ä¸ô
DATE_SUB()
´ÓÈÕÆÚ¼õÈ¥Ö¸¶¨µÄʱ¼ä¼ä¸ô
DATEDIFF()
·µ»ØÁ½¸öÈÕÆÚÖ®¼äµÄÌìÊý
DATE_FORMAT()
Óò»Í¬µÄ¸ñʽÏÔʾÈÕÆÚ/ʱ¼ä
SQL Server Date º¯Êý
ÏÂÃæµÄ±í¸ñÁгöÁË SQL Server ÖÐ×îÖØÒªµÄÄÚ½¨ÈÕÆÚº¯Êý£º
º¯ÊýÃèÊö
GETDATE()
·µ»Øµ±Ç°ÈÕÆÚºÍʱ¼ä
DATEPART()
·µ»ØÈÕÆÚ/ʱ¼äµÄµ¥¶À²¿·Ö
DATEADD()
ÔÚÈÕÆÚÖÐÌí¼Ó»ò¼õÈ¥Ö¸¶¨µÄʱ¼ä¼ä¸ô
DATEDIFF()
·µ»ØÁ½¸öÈÕÆÚÖ®¼äµÄʱ¼ä
CONVERT()
Óò»Í¬µÄ¸ñʽÏÔʾÈÕÆÚ/ʱ¼ä
SQL Date Êý¾ÝÀàÐÍ
MySQL ʹÓÃÏÂÁÐÊý¾ÝÀàÐÍÔÚÊý¾Ý¿âÖд洢ÈÕÆÚ»òÈÕÆÚ/ʱ¼äÖµ£º
DATE - ¸ñʽ YYYY-MM-DD
DATETIME - ¸ñʽ: YYYY-MM-DD HH:MM:SS
TIMESTAMP - ¸ñʽ: YYYY-MM-DD HH:MM:SS
YEAR - ¸ñʽ YYYY »ò YY
SQL Server ʹÓÃÏÂÁÐÊý¾ÝÀàÐÍÔÚÊý¾Ý¿âÖд洢ÈÕÆÚ»òÈÕÆÚ/ʱ¼äÖµ£º
DATE - ¸ñʽ YYYY-MM-DD
DATETIME - ¸ñʽ: YYYY-MM-DD HH:MM:SS
SMALLDATETIME - ¸ñʽ: YYYY-MM-DD HH:MM:SS
TIMESTAMP - ¸ñʽ: ΨһµÄÊý×Ö
SQL ÈÕÆÚ´¦Àí
Èç¹û²»É漰ʱ¼ä²¿·Ö£¬ÄÇôÎÒÃÇ¿ÉÒÔÇáËɵرȽÏÁ½¸öÈÕÆÚ£¡
¼ÙÉèÎÒÃÇÓÐÏÂÃæÕâ¸ö "Orders" ±í£º
OrderIdProductNameOrderDate
1
computer
2008-12-26
2
printer
2008-12-26
3
electrograph
2008-11-12
4
telephone
2008-10-19
ÏÖÔÚ£¬ÎÒÃÇÏ£Íû´ÓÉϱíÖÐÑ¡È¡ OrderDate Ϊ "2008-12-26" µÄ¼Ç¼¡£
ÎÒÃÇʹÓÃÈçÏ SELECT Óï¾ä£º
SELECT * from Orders WHERE OrderDate='2008-12-26'
½á¹û¼¯£º
OrderIdProductNameOrderDate
1
computer
2008-12-26
3
electrograph
2008-12-26
ÏÖÔÚ¼ÙÉè "Orders" ÀàËÆÕâÑù£¨Çë×¢Òâ "OrderDate" ÁÐÖеÄʱ¼ä²¿·Ö£©£º
OrderIdProductNameOrderDate
1
computer
2008-12-26 16:23:55
2
printer
2008-12-26 10:45:26
3
electrograph
2008-11-12 14:12:08
4
telephone
2008-10-19 12:56:10
Èç¹ûÎÒÃÇʹÓÃÉÏÃæµÄ SELECT Óï¾ä£º
SELECT * from Orders WHERE OrderDate='2008-12-26'
ÄÇôÎÒÃǵò»µ½½á¹û¡£ÕâÊÇÓÉÓڸòéѯ²»º¬ÓÐʱ¼ä²¿·ÖµÄÈÕÆÚ¡£
Ìáʾ£ºÈç¹ûÄúÏ£Íûʹ²éѯ¼òµ¥ÇÒ¸üÒ×ά»¤£¬ÄÇôÇë²»ÒªÔÚÈÕÆÚÖÐʹÓÃʱ¼ä²¿·Ö£¡
Ïà¹ØÎĵµ£º
jspÁ¬½Ósql server2005
£¨¾²âÊÔÁ¬½Ó³É¹¦£©
½Ó´¥Java»òÕßJSP£¬ÄÑÃâ»áʹÓõ½Êý¾Ý¿â
SQL Server
2000/2005£¨ÎÒʹÓÃ2005±ê×¼°æ[9.0.3054]²âÊÔ£©£¬¾¹ý×Ô¼ºµÄËÑË÷ºÍÑо¿£¬Ê¹ÓÃJDBCÁ¬½ÓSQL
Server³É¹¦£¬ÌØ´ËÕûÀí·½·¨£¨Ê¹ÓÃEclipse 3.2£©ÈçÏ¡£
×¼±¸¹¤×÷
Ê×ÏÈ£¬²Ù×÷ϵͳ
Öа²×°ºÃSQL Server
2000/2005£¬È ......
ÔÚWindows 2003 sp1·þÎñÆ÷ÉÏȱʡ°²×° MS SQL Server 2005 ¼òÌåÖÐÎÄÆóÒµ°æ£¬ÔÚÁ¬½Ó·þÎñÆ÷ʱÏÔʾ“²»ÔÊÐíÔ¶³ÌÁ¬½Ó”¡£
¾ßÌåÏÔʾÈçÏ£º(xxxxxsqlΪ·þÎñÆ÷Ãû£¬ÔÚ±¾µØ²Ù×÷)
C:\Documents and Settings\Administrator>sqlcmd -S xxxxxsql
HResult 0x2£¬¼¶±ð 16£¬×´Ì¬ 1
ÃüÃû¹ÜµÀÌṩ³ÌÐò: ÎÞ·¨´ò¿ªÓë SQL Server ......
c06 --------------7545623Ìõ
c05---------------1032652Ìõ
vc01--------------427741Ìõ
SQL Statement from editor:
select c0602 "ÉÌÆ·±àÂë",c0625 "ÉÌÆ·ÌõÂë",
c0103 "ÉÌÆ·Ãû³Æ",c0104 "¹æ¸ñ",c060 ......
SQLÖÐDATEADDºÍDATEDIFFµÄÓ÷¨
ÈÕÆÚ:2008-07-17 ×÷Õß:ϲ騰С¶þ 來Ô´:PHPChina
ͨ³££¬妳ÐèÒª獲µÃ當Ç°ÈÕÆÚºÍ計ËãһЩÆäËûµÄÈÕÆÚ£¬ÀýÈ磬妳µÄ³ÌÐò¿ÉÄÜÐèÒªÅÐ斷Ò»個ÔµĵÚÒ»Ìì»òÕß×îááÒ»Ìì¡£妳們´ó²¿·ÖÈË´ó¸Å¶¼ÖªµÀÔõ樣°ÑÈÕÆÚ進ÐзָÄê ......