Select to view content in your preferred language

Calculate a date field using the field calculator

13974
9
05-15-2014 09:55 AM
DavidCrosby
Esri Contributor
I am using the field calculator as part of a GeoEvent Service.  I wish to poll a FS for input and use the field calculator to populate a date field on its way to the add feature output connector.  I can't find documentation on what expression to use to populate the field.  Any ideas?  I found $ReceivedTime though this does not seem to work.

Thanks!
0 Kudos
9 Replies
RJSunderman
Esri Regular Contributor

Hey David -

I think the GeoEvent property you want to use is $RECEIVED_TIME ... not $ReceivedTime.  If you specify $RECEIVED_TIME as the Field Calculator expression, you should be able to time stamp each GeoEvent received from the Poll an ArcGIS Server for Features inbound connector with the server's current date/time.

Correction:  When using a Field Calculator you need to use the functions receivedTime() and currentTime() as Vlad indicates below. Apologies for the misdirection.  - RJ

I don't know that these "macros" are well documented ... the easiest way I know to find them is to review the list presented when configuring a filter expression. That dialog includes the attribute fields of known GeoEvent Definitions, known event field tags, and the GeoEvent property values (e.g. "macros") you can use in expressions.

[ATTACH=CONFIG]33899[/ATTACH]

- RJ

0 Kudos
RafaelDetoni
Deactivated User

I realized a comparison between a date I had with the variable $RECEIVED_TIME but did not work properly. What am I doing wrong?date.png

0 Kudos
RJSunderman
Esri Regular Contributor

Rafael - sorry for the delay in responding to your post to the forum.

There are some limits with how a Filter is able to parse a string representation of a date/time in order to evaluate a less-than / greater-than expression. Combining a date value and a time value together is not working. For example, instead of doing something like TIME_START = 3/16/2012 02:25:31 PM you need to write separate expressions for the date and time and then combine them using logical operators (AND, OR).

For example, you cannot do this:

Capture.png

But you could do something like this:

Capture2.png

Also, you might try working with the date/time values as long integers representing Epoch millisecond values. I know that within a Field Calculator you can perform simple arithmetic on a date/time to add, for example, an hour's worth of milliseconds to a value:  TIME_START + (60 * 60 * 1000). I'm not sure without conducting some experiments how a Filter will interpret an expression such as:  TIME_START >= 1331864731000.

Hope this information is of some help -

RJ

StephanieKiefer
Deactivated User

I am also curious about how to calculate the date using the field calculator. Does anyone have a suggestion?

I added a new feature to a feature service in arcMap and would like to calculate the date.

0 Kudos
RichardFairhurst
MVP Honored Contributor

For a literal date value in VB Script you can type:

#12/31/2013#

Or:

DateSerial(2013, 12, 31)

For Python you can use:

datetime.date(2013, 12, 31)

0 Kudos
VladislavPlechnoy
Emerging Contributor

Guys,

Field Calculator processor currently supports two functions that you can use:

1) receivedTime() - returns time stamp that was attached to GeoEvent by the GeoEvent Processor when it was received;

2) currentTime() - generates new time stamp at the moment when Field Calculator evaluates an expression.

For instance if you want to calculate the time delay between the point in time when geoevent was received and point in time when geovent was processed by Field Calculator you can write an expression like this:

                                             currentTime() - receivedTime()

This will return a number of milliseconds in between the two.

Thanks!

ChristineWiltawsky
Deactivated User

Is this answer still up-to-date? receivedTime() and currentTime() are not working for me in FieldCalculator. I'm using GeoEvent Extension 10.4.

0 Kudos
NathanKemphues
Occasional Contributor

I was struggling with this in 10.3.1. The fix was to use a date field type. 

0 Kudos
RJSunderman
Esri Regular Contributor

Christine Wiltawsky​​ - Yes, I just verified using a system configured with 10.4 Patch1.

Note that I've chosen to blur irrelevant property values since, in my example, I'm writing to an existing field of type Date.

Capture.png