System i Blogger

Jan 9 2009   5:10PM GMT

CL - Convert a date to julian in CLP



Posted by: David Vasta
CL Programming, Code Snippets

Convert a date to julian in CLP
Posted By: Jamie Flanary

LINK TO SITE I TOOK THIS FROM

CODE:
  1. PGM
  2. DCL &DATE6 *CHAR LEN(6)
  3. DCL &DATE5 *CHAR LEN(5)
  4. RTVSYSVAL QDATE RTNVAR(&DATE6)
  5. CVTDAT DATE(&DATE6) TOVAR(&DATE5) TOFMT(*JUL) TOSEP(*NONE)
  6. ADDPFM LIB1/FILEX MBR(’MBR’ *CAT &DATE5)
  7. .
  8. .
  9. .
  10. ENDPGM
  11.  
  12. or use a c function
  13.  
  14. The following is an alternative program that uses the ILE bindable API, Get
  15. Current Local Time (CEELOCT), to convert a date to Julian format. To create this
  16. program, you must use the CRTBNDCL command alone or the CRTCLMOD
  17. command and the CRTPGM command together.
  18. PGM
  19. DCL &LILDATE *CHAR LEN(4)
  20. DCL &PICTSTR *CHAR LEN(5) VALUE(YYDDD)
  21. DCL &JULDATE *CHAR LEN(5)
  22. DCL &SECONDS *CHAR 8 /* Seconds from CEELOCT */
  23. DCL &GREG *CHAR 23 /* Gregorian date from CEELOCT */
  24. /* */
  25. CALLPRC PRC(CEELOCT) /* Get current date and time */ +
  26. PARMS (&LILDATE)   /* Date in Lilian format */ +
  27. &SECONDS /* Seconds field will not be used */
  28. &GREG       /* Gregorian field will not be used */
  29. *OMIT         /* Omit feedback parameter so exceptions +
  30. are signalled */
  31.  
  32. CALLPRC PRC(CEEDATE) +
  33. PARMS (&LILDATE) /* Today’s date */ +
  34. &PICTSTR /* How to format */ +
  35. &JULDATE /* Julian date */ +
  36. *OMIT
  37.  
  38. ADDPGM LIB1/FILEX MBR(’MBR’ *CAT &JULDATE’)
  39. ENDPGM

Comment on this Post


You must be logged-in to post a comment. Log-in/Register