Working with Timestamps in R
The SF timestamp is formatted as UNIX timestamp with millisecond precision. For our R scripting engine, this looks like an ordinary numeric. To create a date object, use the following snippet:
To use a R date object outside of a script, define a script result variable with data type either "timestamp" or "string". Using "string" has the advantage of formatting the date-time object as you like but when using a timestamp the widget will adjust the representation to the displayed time frame. Use the following code snippets to correctly format the date-objects to meet the correct output format requirements:
String as output,
Timestamp as output,
Alternatively look at the lubridate package. It offers many functions for handling timestamps and datetime objects in very intuitive way, just remember that lubridate is also expecting a timestamp in seconds and not in milliseconds, so devide the timestamp you get from your data by 1000.
Last updated