5 pts.
 UPDATE a year from an ISO date field using SQL
Dear Sir/Madam, How can I update the year from a date field. For example the date file contains '2008-12-31' and I would like to use I-Series navigator's SQL to update the date field above with '2007-11-31'.But my intention for the update here is to decrease/deduct the year by 1 year and the month by 1 month as well as there could be thousands of different date which i cannot update one by one. The date field is in ISO format. Thanks and Best Regards, Kenny Ng

Software/Hardware used:
AS/400 I-Series navigator SQL
ASKED: August 25, 2009  9:33 AM
UPDATED: August 25, 2009  1:24 PM

Answer Wiki:
We need more specificity -- is your field a date type? If the date that you have is a date type then I think this will work. If you have a date in a char or numeric field then it needs more work. Make a test file and try this. It should update all records in MyFile reducing MyDate Update Myfile Set MyDate = MyDate - 1 YEAR - 1 MONTH; It should reduce the date by 1 year and to the same date one month before .. if the date exceeds the number in the month then the last day of the month. Phil
Last Wiki Answer Submitted:  August 25, 2009  1:24 pm  by  philpl1jb   44,180 pts.
All Answer Wiki Contributors:  philpl1jb   44,180 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _