Writing a Datetime field to Firestore from workflows

Hi, we're trying to write a timestamp field to Firestore as part of a document. We have read other posts on this (for example, Firestore dates written as strings, not Timestamps) but these all seem to be relative to an app context.

When we try writing a moment or date object, it's written in Firestore as a number. Similarly, if we convert the moment or date object to a string, or ISO string, it is also stored as a string.

In an attempt to resolve this, we create the Firestore document, then update it using the following two modules :

to set the value of the timestamp, and

to update the Firestore document. But however we try, we can only manage that it's stored as a string or number, never as a timestamp.

Can anyone help with a syntax that enables Firestore to understand the data as a timestamp? thanks in advance.

I think you're running into and issue with your approach is in using moment().valueOf() returns an Epoch (number). Using moment().toDate() will return a date object.

The approach to write the document back to the datastore looks okay as you are setting the date value explicitly in the value field. Change your moment reference and you should be good.

Also since you're only getting the current time you could do something like this as well:

  "date_begin": {{ new Date() }},

Hi Brett,
Thanks so much for your prompt reply. Unfortunately in both cases, it's being stored as a string. From what I have been able to glean from other posts based on apps, somewhere along the way the timestamp nature of the object is being lost, and it's being interpreted as a string.

The only solutions I've been able to find have been for apps. In workflows, I haven't found a thing. Any other ideas ?

Thanks again,


What are these cases? Can you provide an example?

If the value gets serialized at some point, then yes, it will be converted to a string. The ways around this are wonky and a pain-point in ReTool, but we've worked around them in many cases.

Oh shoot, you're in workflows, sorry I should have paid better attention, yeah this is not working currently in workflows, from my experience.