Date field in RPGLE

190 pts.
Tags:
RPGLE
If have a statement in RPGLE which runs fine online but errors out in batch.
D DateField       S               d   datfmt(*mdy)
D S1Dte           S              6  0

Datefield = %date( s1Dte   : *MDY );
Error: "Date, Time or Timestamp variable which contained a value which is not valid."


Software/Hardware used:
date,time
1

Answer Wiki

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

Check out your system date format, it may be different than what you are expecting.

DSPSYSVAL SYSVAL(QDATFMT)

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.
  • ToddN2000
    Have you tried running it in debug to see what is happening? What is the system default for the date format? Maybe they are incompatible.
    133,750 pointsBadges:
    report
  • Msatbh
    It's MDY.
    190 pointsBadges:
    report
  • Msatbh
    I tried dumbing Value in datefileld, it is 01/01/40 when its halting at statement "Datefield = %date( s1Dte   : *MDY );"
    190 pointsBadges:
    report
  • ToddN2000
    When the job halts, take a dump and post the values of S1Dte and DateField. Those appear to be the only values and I do not see how they are being initialized.
    133,750 pointsBadges:
    report
  • Msatbh

    Here are the values of S1Dte and DateField.

    S1DTE                 PACKED(6,0)          160902

    DATEFIELD             DATE(8)              '01/01/40'

    190 pointsBadges:
    report
  • pdraebel
    Looks like SDTE value 160902 is in YMD format, certainly not MDY.
    7,545 pointsBadges:
    report
  • ToddN2000
    Are you looking to convert the current system date to that format or the date being used in the program coming from a field or passed as a parameter?
    133,750 pointsBadges:
    report
  • Msatbh
    Thanks!
    190 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: