## Query 400- Number of Days Calculation

185 pts.
Tags:
query 400
Hi,

Using Query 400, i want to find difference between julian dates. It should include both leap year and non-leap year.

Suggest any idea.

Software/Hardware used:
as/400

Thanks. We'll let you know when a new response is added.

Hi Vjaya,

I havent tried the similar case in QUERY/400.
But, I found a solution by searching it in google.

http://www.itjungle.com/fhg/fhg062806-story01.html

You can find the way to do the same(with sample code) in above link.

## Discuss This Question: 12 Replies

Thanks. We'll let you know when a new response is added.
• Any options other than query/400? Phil
report
• No Phil, I have to do it using query/400.
report
• You're in for a great deal of pain ..as shown in the link Pradeep offerfed. Query/400 is mature and doesn't offer SQL date operations. Phil
report
• I have to do it using query/400. Why? Nobody else has to do it using Query/400. First thing you need to understand is that "Julian" is a date format. It is not a data type. DATE is a data type. And you can format a date any way you need for presentation. Also, a 5-digit numeric field can hold a value in Julian date format. Do you have a DATE field or is it a numeric field with a Julian date value? Tom
report
• Hi Tom, ya. It is a numeric field with a Julian date value. for EX: 111350 like this. I have to find the difference by considering it as a date field and not a numeric field. Please suggest any idea, Thanks. Jayashree V.
report
• It is a numeric field with a Julian date value. for EX: 111350... For Query to recognize that as a date value while keeping the Julian format, I think that you need to create a 7-digit result field and assign it a value of 1900000 + (111350). That is, add 1900000 to your numeric field so that your 7-digit result field will contain 2011350. You should then be able to turn that into a 7-character result that can actually become a real DATE result. You can possibly get away without using an intermediate numeric result field, but it might help reduce complexity in the conversion functions. Once you have the values converted into real DATE fields, date durations will be much easier. Doing it outside of Query/400 is still a better option. And not using numeric fields with odd values like you're stuck with would be even better, but that's probably not a choice that you have at the moment. I'd still like to know why you have to use Query/400. Every AS/400 since maybe version 2 of OS/400 has included alternatives as part of the base system. Are you still using version 1? Or is this a homework assignment? (Or is it just that the alternatives aren't known?) Tom
report
• Hi Tom, Thanks for ur explanation. The requirement is to be done using query 400. When we convert date fiels to a 7 digit character, how it will be possible to convert it to a normal date format(MM/DD/YYYY)? Jayashree
report
• The requirement is to be done using query 400. We understand that. We just want to know why anyone would make such a poor requirement when other alternatives are available and better. We want to know in order to understand the problems that people face. When we convert date fiels to a 7 digit character, how it will be possible to convert it to a normal date format(MM/DD/YYYY)? When it's converted to "7 digit character", what format are the digits in? In any case, in order to display a "7 digit character" value as "date format(MM/DD/YYYY)", the first thing to do is convert it back to a real DATE field. Tom