Best answer

Transform a date to a number

  • 9 June 2020
  • 4 replies
  • 320 views

Userlevel 1

Hi Guys,

 

I need to transform a date like this YYYY MM DD HH MM SS in a number which will be like this YYYYMMDDHHMMSS.

so If I have a creation date of 2020-06-09T17:52:13 the number will be a like this : 20200609175213

I check the "format" tool in zapier but it's not doing it. Anyone got an idea ?

 

Thanks in advance 

icon

Best answer by Danvers 12 June 2020, 15:38

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

4 replies

Userlevel 7
Badge +12

Hi @Avner!

 

You should be able to do this using the Formatter by entering a custom value for the ‘From Format’. First, make sure that you’ve chosen the ‘Date’ option and then the Format option. 

 

For the ‘From’’ Format, don’t choose one of the options from  the list, instead select ‘Custom’. You can then type in the Format that you need. This guide explains how you can do that: Can I use a date that’s not on the list of formats?

 

Looking at the format that you want, perhaps try: YYYYMMDDHHmmss

 

If you’re looking to create a number as a unique identifier (or for similar reasons) then I’d recommend using the ‘Epoch’ time stamp, which is the ‘X’ option in the To Format:

Firstly, this is easier to do with the Formatter and also because it allows you to convert the number back to a ‘human readable’ time if you ever need to. It might not be right for what you need in this case, but I thought I’d mention it just in case!

Userlevel 1

Hi @Danvers

I've tried both of your solutions but none of them are working.

"For the ‘To’ Format, don’t choose one of the options from  the list, instead select ‘Custom’." => I cannot write a "real" custom option...I'm forced to choose what zapier propose me even in custom mode.

"If you’re looking to create a number as a unique identifier (or for similar reasons) then I’d recommend using the ‘Epoch’ time stamp, which is the ‘X’ option in the To Format:" => this method send a 0 in my database instead of sending a number…

So I'm stuck with the same problem. :disappointed_relieved:

Userlevel 7
Badge +12

Hmm, if the step can properly convert the date then it should give you a number string as opposed to just a 0. 

 

I just saw that I mis-typed something in my first response. It’s the FROM format that needs the custom value, not the To format, sorry about that. I’m going to edit that in my original reply!

 

For the from format, you should be able to type a custom value. In the dropdown choose the Custom option then click back into the box and start typing here’s a link to a gif that shows that.

 

For the To Format, you can just pick the ‘X’ option from the dropdown box. 

Userlevel 2
Badge +1

@Danvers

 

The FORMAT feature was awesome for me - one point of interest, if you’re transforming multiple fields from the incoming payload one must have separate transforms for each, it can’t do them all in one transform. No big deal - just add more steps of the same type - format/transform 

I was doing epoch to human hence I had several date fields and did a step for each individually since it didn’t work when I bunch them all into one transform step

Good advice. Thank you