datetimeåtimestampæ¯åºç°å¨MySQLåSqlServeræ°æ®åºä¸çã
MySQLä¸datetimeåtimestampçåºå«ï¼
(ä¸)èå´ä¸åã
âdatetimeâ 以'YYYY-MM-DD HH:MM:SS'æ ¼å¼æ£ç´¢åæ¾ç¤ºDATETIMEå¼ãæ¯æçèå´ä¸º'1000-01-01 00:00:00'å°'9999-12-31 23:59:59'TIMESTAMPå¼ä¸è½æ©äº1970ææäº2037
(äº)å¨åä¸åã
1ï¼TIMESTAMP
â 4个åèå¨åï¼Time stamp value is stored in 4 bytesï¼
â¡å¼ä»¥UTCæ ¼å¼ä¿åï¼ it stores the number of millisecondsï¼
â¢æ¶åºè½¬å ï¼åå¨æ¶å¯¹å½åçæ¶åºè¿è¡è½¬æ¢ï¼æ£ç´¢æ¶å转æ¢åå½åçæ¶åºã
2ï¼datetime
â 8个åèå¨åï¼8 bytes storageï¼
â¡å®é æ ¼å¼å¨åï¼Just stores what you have stored and retrieves the same thing which you have stored.ï¼
â¢ä¸æ¶åºæ å ³ï¼It has nothing to deal with the TIMEZONE and Conversion.ï¼
注ï¼TIMESTAMPåçæ¾ç¤ºæ ¼å¼ä¸datetimeåç¸åã
SqlServerä¸datetimeåtimestampå¨ä¸ç¨æ³åºå«åºæ¬é½å·®ä¸å¤ã
datetime ï¼
SqlServerä¸ç¨ä¸¤ä¸ª 4 åèçæ´æ°å é¨åå¨ datetime æ°æ®ç±»åçå¼ã第ä¸ä¸ª 4 åèåå¨ base dateï¼å³ 1900 å¹´ 1 æ 1 æ¥ï¼ä¹åæä¹åç天æ°ãåºç¡æ¥ææ¯ç³»ç»åèæ¥æãä¸å 许æ©äº 1753 å¹´ 1 æ 1 æ¥ç datetime å¼ãå¦å¤ä¸ä¸ª 4 åèåå¨ä»¥åå¤å毫ç§æ°æ代表çæ¯å¤©çæ¶é´ã
注ï¼smalldatetime æ°æ®ç±»ååå¨æ¥æåæ¯å¤©çæ¶é´ï¼ä½ç²¾ç¡®åº¦ä½äº datetimeãSQL Server å° smalldatetime çå¼åå¨ä¸ºä¸¤ä¸ª 2 åèçæ´æ°ã第ä¸ä¸ª 2 åèåå¨ 1900 å¹´ 1 æ 1 æ¥åç天æ°ãå¦å¤ä¸ä¸ª 2 åèåå¨åå¤åçåéæ°ãæ¥æèå´ä»1900 å¹´ 1 æ 1 æ¥å° 2079 å¹´ 6 æ 6 æ¥ï¼ç²¾ç¡®å°åéã
timestampï¼
timestamp è¿ç§æ°æ®ç±»å表ç°èªå¨çæçäºè¿å¶æ°ï¼ç¡®ä¿è¿äºæ°å¨æ°æ®åºä¸æ¯å¯ä¸çãtimestamp ä¸è¬ç¨ä½ç»è¡¨è¡å çæ¬æ³çæºå¶ãåå¨å¤§å°ä¸º 8 åèã