Question

Create a customized DateTime field?

  • 22 July 2021
  • 8 replies
  • 23 views

I am using AttributeCreator to add a new date attribute, and this is what I have in the attribute value:

@DateTimeFormat(@round(@DateTimeNow(localUnzoned),0),%Y-%m-%d %H:%M:%S)

 

I am getting an warning and null value in my output:

 

I have tried using DataTimeConverter, DatetimeCalculator, and DateTImeStamper. All works, but it doesnt give me the output I want.

 

Example: 2021-07-21 10:30:40

 

Any suggestion?

 

 

 


8 replies

Badge +5

What warning are you getting? Your example works for me without any changes.

What warning are you getting? Your example works for me without any changes.

either an error:

An error occurred while attempting to convert the '' component of a date. A possible reason for this is that the data in the date field may be corrupt

 

or a warning:

Attribute(string) : `fme_expression_warnings{0}.message' has value `Failed to evaluate expression '@DateTimeFormat(20210721171660,%Y-%m-%d %H:%M:%S)'. Result is set to null'

Userlevel 3
Badge +18

Works fine here. Maybe try changing the date format of your PC? Just a wild guess.

Badge +5

either an error:

An error occurred while attempting to convert the '' component of a date. A possible reason for this is that the data in the date field may be corrupt

 

or a warning:

Attribute(string) : `fme_expression_warnings{0}.message' has value `Failed to evaluate expression '@DateTimeFormat(20210721171660,%Y-%m-%d %H:%M:%S)'. Result is set to null'

the @round function isn't aware it is working on a time so rounds 59.9 seconds to 60 seconds making it an invalid time. Can you get by without that? Maybe truncate after the formatting if you are getting decimal seconds.

Userlevel 3
Badge +18

either an error:

An error occurred while attempting to convert the '' component of a date. A possible reason for this is that the data in the date field may be corrupt

 

or a warning:

Attribute(string) : `fme_expression_warnings{0}.message' has value `Failed to evaluate expression '@DateTimeFormat(20210721171660,%Y-%m-%d %H:%M:%S)'. Result is set to null'

Ah, that would be the problem. You could use something like @floor or @left(%S,2)

either an error:

An error occurred while attempting to convert the '' component of a date. A possible reason for this is that the data in the date field may be corrupt

 

or a warning:

Attribute(string) : `fme_expression_warnings{0}.message' has value `Failed to evaluate expression '@DateTimeFormat(20210721171660,%Y-%m-%d %H:%M:%S)'. Result is set to null'

I have taken out the @round, currently is @DateTimeFormat(@DateTimeNow(localUnzoned),%Y-%m-%d %H:%M:%S) and now its giving me an error, the same one I shown above. I am not getting any warnings.

Works fine here. Maybe try changing the date format of your PC? Just a wild guess.

error - An error occurred while attempting to convert the '' component of a date. A possible reason for this is that the data in the date field may be corrupt

Badge +5

either an error:

An error occurred while attempting to convert the '' component of a date. A possible reason for this is that the data in the date field may be corrupt

 

or a warning:

Attribute(string) : `fme_expression_warnings{0}.message' has value `Failed to evaluate expression '@DateTimeFormat(20210721171660,%Y-%m-%d %H:%M:%S)'. Result is set to null'

Can you break it down into parts. So first put @DateTimeNow(localUnzoned) into an attribute and log what that gives.

Reply