Skip to main content
Question

DateFormat showing as null in AttributeCreator step

  • November 27, 2019
  • 5 replies
  • 26 views

I am passing a date UserParameter into a workbench and am then trying to convert it from the standard FME format to dd/mm/yyyy

Parameter is formatted as yyyy-mm-dd and if I just use the Parameter the value unformatted

it outputs as yyyyddmm eg 1950-01-01 becomes 19500101

I want it to output in dd/mm/yyyy format but if use dateformat($(PositionEffective).%d/%m/%y) a null is returned.

Thanks in advance

5 replies

ebygomm
Influencer
Forum|alt.badge.img+39
  • Influencer
  • November 27, 2019

Are you on a older version of FME?  Should be DateTimeFormat with capital Y if you want 1950

@DateTimeFormat($(date),%d/%m/%Y)

Forum|alt.badge.img
  • November 27, 2019

You might have to force it with a DateTimeConverter after the AttributeCreator.


sipsysigh
Contributor
Forum|alt.badge.img+7
  • Contributor
  • November 27, 2019

Hi @left65,

As @ebygomm mentions, it looks like you got the syntax slightly wrong.

Instead of:

dateformat($(PositionEffective).%d/%m/%y)

in your example, it should be:

@DateTimeFormat($(PositionEffective),%d/%m/%Y)

 

You can use this function directly within the AttributeCreator, like this:

0684Q00000ArLIsQAN.png

Edited to actually include the screenshot! Not sure what happened there...

 

 

Hope this helps.

Si


Forum|alt.badge.img
  • November 27, 2019

Hi @left65

if the date comes in yyyy-mm-dd format (i.e. not in FME date format), it needs to be parsed first. You can use

@DateTimeFormat(@DateTimeParse(@Value(_date),%Y-%m-%d),%d/%m/%Y

expression to parse and then format your date. There is also DateTimeConverter transformer that will help you avoid writing nested functions :)


ebygomm
Influencer
Forum|alt.badge.img+39
  • Influencer
  • November 27, 2019
lenaatsafe wrote:

Hi @left65

if the date comes in yyyy-mm-dd format (i.e. not in FME date format), it needs to be parsed first. You can use

@DateTimeFormat(@DateTimeParse(@Value(_date),%Y-%m-%d),%d/%m/%Y

expression to parse and then format your date. There is also DateTimeConverter transformer that will help you avoid writing nested functions :)

My version of FME will format from yyyy-mm-dd without parsing first.

Incidentally, i think in this case it's a date parameter that is displayed as yyyy-mm-dd when you selected but is actually stored as an FME date.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings