× 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.



Hi Jeff,

have a record containing 2 fields containing a numeric representation
of a date (8,2) and 2 associated fields containing a numeric
representation of an associated time (6,0).fields.

As so many others have said, I don't understand the 8,2 date. I don't know what format that is? Is it YYYYMM.DD? Or YYMMDD.CC? Or, what is it?

Bearing in mind that I'm not sure how that date format works, I'll give a sample with YYYYMM.DD dates -- and if that's not right, you might have to modified this code accordingly:

D ts1 s Z
D ts2 s Z
D diff s 10i 0

/free

ts1 = %date( %dec(date1*100:8:0) : *ISO )
+ %time(time1:*HMS);
ts2 = %date( %dec(date2*100:8:0) : *ISO )
+ %time(time2:*HMS);
diff = %diff(ts1: ts2: *seconds);

The only thing that was even slightly tricky is that the first parameter to %DATE() has to be a numeric field with no decimal places (or a character field...) So I simply multiplied it by 100, and used %DEC() to make the intermediate result be an 8,0 field. From there, the rest was easy. Fairly basic %DATE() + %TIME() = %TIMESTAMP() logic.

Not sure why you brought up SQL. This is actually easier to do in RPG than it would be in SQL (though, SQL is certainly capable, it'd require a bit more work...)


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.