Skip to main content
Question

Create a customized DateTime field?


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

gazza
Contributor
Forum|alt.badge.img+6
  • Contributor
  • July 22, 2021

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


  • Author
  • July 23, 2021
gazza wrote:

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'


jkr_wrk
Influencer
Forum|alt.badge.img+29
  • July 23, 2021

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


gazza
Contributor
Forum|alt.badge.img+6
  • Contributor
  • July 24, 2021
leighz wrote:

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.


jkr_wrk
Influencer
Forum|alt.badge.img+29
  • July 24, 2021
leighz wrote:

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)


  • Author
  • July 26, 2021
leighz wrote:

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.


  • Author
  • July 26, 2021
jkr_da wrote:

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


gazza
Contributor
Forum|alt.badge.img+6
  • Contributor
  • July 26, 2021
leighz wrote:

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.


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