Select to view content in your preferred language

Attribute Assistant - Timestamp question

2586
13
Jump to solution
02-06-2017 09:51 AM
TimWitt2
MVP Alum

Hey everybody,

I am trying to get my timestamp in a certain format: YYYY-MM-DDThh:mm:ss.s but I am not able to do it.

As an example it needs to look like this: 2017-02-20T23:16:45.7

Is this even possible? If so, what would be the expression I need?

Thanks,

Tim

0 Kudos
13 Replies
TimWitt2
MVP Alum

Row Info
Row Number 20
TableName: *
FieldName: DateUpdate
ValueInfo: DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
ValueMethod: EXPRESSION
On Create: 1
On Change: 1

Checking for Subtype Restriction
Field Name: DateUpdate was found at index: 68
Trying: EXPRESSION
Checking to verify there is a field to store the expression
Expression to be eval: DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
ERROR: evaluating the expression for feature in Brevard_Nena_Street with OID of 42394
Object required: 'DateTime'
Finished: EXPRESSION

0 Kudos
MikeMillerGIS
Esri Frequent Contributor

Using your value info through the debugger, I get a proper date and the process completes

>? args[0]

"yyyy-MM-dd HH:mm:ss"

>? DateTime.Now.ToString(args[0])

"2017-02-07 14:08:04"

What version are you using? I would suggest trying out the preview of the next release

https://github.com/Esri/local-government-desktop-addins/tree/dev/PreviewBuilds

Also, you need a string field as the date/time field will display the date based on your system date time formatting.

0 Kudos
MikeMillerGIS
Esri Frequent Contributor

Hold on, why are you using this in expression? Just use the TIMESTAMP value method and yyyy-MM-dd HH:mm:ss as the value info

TimWitt2
MVP Alum

Michael thanks for the help. What I will end up doing is create a DATE field and a TIME field and then write an expression for my DateUpdate field looking like this: [DATE] & "T" & [TIME] & "-05:00"