Author: Abhishek Bathwal

The Blog contains the Dataweave 2.0 code for converting the Date Format (“yyyy-MM-dd) to Julian Date Format.

Datawave 2.0 Code:

%dw 2.0
output application/json
import * from dw::core::Strings
fun year(date) = (date as Date).year
fun dayOfyear(date) = (date as Date).dayOfYear
fun C_value(date)= floor ((year(date) – (1900))/100)
fun JulianDate(date) = C_value(date) ++ (year(date) as String) [2 to 3] ++ leftPad(dayOfyear(date),3,”0″)

{
JulianDate: JulianDate(<Provide some Date>)
}

When Current Date is Provided:

Input:

{
“Date”: now()
}

Output:

{  
“JulianDate”: “120322”
}

When Some Manual Date is Provided:

Input:

{

“Date”: “2020-11-18”

}

Output:


 “JulianDate”: “120323”

}

When Provided with DateTime:

Input:

{
“Date”: “2020-11-19T13:54:02.011+05:30”

}

Output:

{  
“JulianDate”: “120324”

}

Leave a Comment