2013-07-22 41 views
2

我們希望更新此示例數據庫中的日期以使其更新。將每個季度代碼增加5年,使19964看起來像20014.通過顯示錶中的數據來驗證結果。我正在使用mySQL Oracle CommandLine Client,並想知道如何將所有采訪日記錄更新5年。如何更新日期類型列?

interview table 
+---------------+--------------+------+-----+---------+-------+ 
| Field   | Type   | Null | Key | Default | Extra | 
+---------------+--------------+------+-----+---------+-------+ 
| interviewdate | date   | YES |  | NULL |  | 
+---------------+--------------+------+-----+---------+-------+ 

interviewdate column 
+---------------+ 
| interviewdate | 
+---------------+ 
| 1995-06-01 | 
| 1995-06-01 | 
| 1995-06-30 | 
| 1995-06-30 | 
| 1995-07-01 | 
| 1995-08-01 | 
| 1995-08-01 | 
| 1995-08-02 | 
| 1995-12-01 | 
| 1995-12-02 | 
| 1995-12-04 | 
| 1996-01-21 | 
| 1996-02-01 | 
| 1996-02-02 | 
| 1996-07-01 | 
| 1996-07-01 | 
| 1996-08-01 | 
| 1996-08-08 | 
| 1996-08-11 | 
| 1997-01-01 | 
| 1997-01-01 | 
| 1997-01-31 | 
| 1997-02-01 | 
| 1997-03-24 | 
| 1997-03-31 | 
| 1997-04-20 | 
| 1997-04-22 | 
| 1997-05-01 | 
+---------------+ 
28 rows in set (0.00 sec) 

我想是這樣的:

UPDATE interview 
SET qtrcode = DATEADD(year, 5, qtrcode); 
ERROR 1305 (42000): FUNCTION jobs.DATEADD does not exist 
+0

參見[MySQL的日期函數引用(HTTP://開發。 mysql.com/doc/refman/5.5/en/date-and-time-functions.html) –

+1

我做了,我做的嘗試的答案是在底部。 – TheAmazingKnight

+0

對不起 - 您使用MS Access中的'DATEADD()'函數。 MySQL的是'DATE_ADD()'(上面鏈接),如'DATE_ADD(interviewdate,INTERVAL 5 year)' –

回答

相關問題