AS/400: Most Recent Date

15 pts.
Tags:
AS/400
Query
Recent Date
Is there a way to write an expression to choose the more recent of two date fields (both in the MMDDYY format)?
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 8  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • carlosdl
    What software or system do you want to do this on?
    84,805 pointsBadges:
    report
  • Subhendu Sen
    What software application are you using now ! that is more important. Is it Java/ VB/ C#/ other prog language.... however, OS is not so important while you write a code on a application software, if it supports on the same OS. Though it is good, if you disclose more about your Q.
    140,150 pointsBadges:
    report
  • hunshabbir7
    More info required?
    2,900 pointsBadges:
    report
  • jraiford
    Sorry, I though I included that somewhere. Query/AS400
    15 pointsBadges:
    report
  • carlosdl
    It's OK.

    I've edited the question, to add a couple of tags.

    I'm sure some AS/400 expert will reply soon.
    84,805 pointsBadges:
    report
  • philpl1jb

    Not in a single query ..

    The first query would output data to a file replacing old data where date_a > date_b.

    The second query would would output data to a file adding data where date_b > date_a

    Both queries would output a field newdate which in the results is date_a for the first query and date_b for the second query

    The comparison of date_a>date_b or date_b > date_a must be done on the dates in yymmdd format so this will require two more result fields in each query to store date_a and date_b in yymmdd format.  Loading these fields will require substrings of the original fields.

     

    54,090 pointsBadges:
    report
  • azohawk

    The dates have to be compared in query400 in yymmdd format.

    In define result fields

    D1         Digits(DATE1)

    Dat1b    substr(d1,5,2) || substr(d1,1,4)

    and repeat for the second date

    Then you can compare Dat1b>Dat2b  

    4,055 pointsBadges:
    report
  • ToddN2000
    Like phipil1jb said, not in one query. I assume you are looking to compare 2 date fields and display/print the greater of the two.

    You would have to convert them to YYMMDD to do the compare.

    Send the output from your query to an output file testing one way
    then change the query to test the other way and add results to same output query.

    Then query your output file to get desired results.
    133,595 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: