× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Sure - once you have a true date value, use the plus sign (+) followed by a number and the word 'days'.

Now if you have a numeric representation, it gets harder. You have to convert that to a true date, probably by using combination of substrings and char() functions, then once you have the new date, convert it back to that number.

Or see if Alan Campin's date UDF can help you - http://www.think400.dk is the link, I think. Dig into the downloadable stuff there.

V5R3 might not have all the casting functionality to let you convert from a character string back to a number - I forget.

OK - ran a test - yes, V5R3 can do this - but it is ugly - heh! Check this out - it adds 5 days to December 13, 2001, assuming MMDDYYYY in your "date" field. Change the substring starting values if the format is different.

SELECT decimal(replace(char(date(substr(char(12132001), 1, 2) || '/' || substr(char(12132001), 3, 2) || '/' || substr(char(12132001), 5, 4)) + 5 days,usa), '/', '')) FROM sysibm/sysdummy1

It goes without saying, you are probably better off with a UDF

Jeff Young wrote:
Is there a way to add or subtract a duration (# of days) to a Date field in SQL.
What I have is a field containing a numeric representation of a date in a file.
I want to use SQL to increment that field by a specific value.

I am using a V5R3 system.


Thanks,
Jeff Young Sr. Programmer Analyst
IBM -e(logo) server Certified Systems Exper - iSeries Technical Solutions V5R2 IBM Certified Specialist- e(logo) server i5Series Technical Solutions Designer V5R3
IBM Certified Specialist- e(logo)server i5Series Technical Solutions Implementer V5R3

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.