How to Convert Numeric to Julian Date

rk1234

Member
Hi Gurus,

How do we convert a numeric 8 value in CCYYMMDD format to a Julian Date.

Should I convert the numeric field to a string then convert it to Julian ?

Please Advise !

Thanks !
 
Hi rk1234,

(nice name ;-)

Welcome aboard!

See the logic below.
The first and last line is only for test purpose in my test APPL

evt_szDate_DATE = string, holds the date in CCYYMMDD format
evt_jdDate01_DATE01 = date, the results date in jdedate (julian) format
evt_szFormattedDate_FDAT = string, work variable to construct date in MM/DD/CCYY format.

evt_szDate_DATE
evt_jdDate01_DATE01
evt_szFormattedDate_FDAT
0001 VA evt_szDate_DATE = FC szDate_DATE
0002 VA evt_szFormattedDate_FDAT = substr([VA evt_szDate_DATE],4,2)
0003 VA evt_szFormattedDate_FDAT = concat([VA evt_szFormattedDate_FDAT],"/")
0004 VA evt_szFormattedDate_FDAT = concat([VA evt_szFormattedDate_FDAT],substr([VA evt_szDate_DATE],6,2))
0005 VA evt_szFormattedDate_FDAT = concat([VA evt_szFormattedDate_FDAT],"/")
0006 VA evt_szFormattedDate_FDAT = concat([VA evt_szFormattedDate_FDAT],substr([VA evt_szDate_DATE],0,4))
0007 // *** Call BSFN: B0800013 ***
0008 Convert String to Date
VA evt_jdDate01_DATE01 <- jdDateConvertedDate
VA evt_szFormattedDate_FDAT -> szStringToConvert
0009 FC jdDate01_DATE01 = VA evt_jdDate01_DATE01

You can apply this logic with your string and date objects.

Hope, this helps!

Good luck,

Zoltán
 
Hi rk1234,

your right,
first convert to a string
second use ConvertStringToDateUsingMask with input your string, your mask (EOA) and output your date

Succes

Marcel Endema
 
if u r interested in progamming aspect then u can use CVTDAT command in CLP
programme

i have implemented an utility for this also which is very handy

or conversion is like this for ex cc040720 then jullian date would b 01(CC)
04(YY) 202(DD)

the number of days (DD) like for jan 31 DD=31 ,,,for feb1 DD=32,,,for dec31
=365 or366 depending on leap year

CC=01 fr 2000 upto 2053
CC=00 fr 1928 upto 1999
 
Back
Top