Converting date format

HI - I have searched and searched on here for help in converting a date format. There is alot of very good help except I can’t find one that helps me. I have a date format of 12-Dec-22 and need it to read Dec 12, 2022. Before I was able to use something like this - {{date MyField “MM/dd/yyyy”}} as my date was yyyymmdd but obviously this wont work . There are about 5 other posts that I looked at and can’t seem to get anything to work.

Any help would be great

Yeah… Your original date format isn’t very cooperative.

Here’s a quick fix: create your own helper named myDate by creating a control script with the following code:

Handlebars.registerHelper('myDate', function(d) {
  let parts = d.split("-");
  return `${parts[1]} ${parts[0]}, 20${parts[2]}`
});

Then you can use it in the template like so:

{{myDate MyField}}

Now this will only work for years 2000-2099… but you and I will both be retired by the time it becomes invalid… :stuck_out_tongue:

LOL you are right about that one!!!

I created the helper and for some reason I have to use {{[MyField]}} instead of {{MyFiled}} whenever I use handlebars but either way I am not getting any result. No errors either. hmmmmm

Quick question, what is the type of the data field? I would suggest to map to a date field in Data Mapper. In that case I would expect the custom pattern to work.

Erik

Every time I try to use the date type I always get the below. I have never been able to successfully map to a date field in Data Mapper.

image

image

Happy too have a quick peek at your data mapper. Could you send it to me? (believe you have my details)

Yes - thank you for looking at this!

Quickly looked at it. Setting the Pattern for the three date fields to: “dd-M-yy” solved things on my end. Using {{date [balance as of] “MM/dd/yyyy”}} should format the date correctly. Although {{date [balance as of]}} is prob rendering the correct format already.

image

YAY!!! Thank you so much. Works perfectly now. So apparently all this time I was just not using the right ‘custom’ date format because I have never been able to get it to work.

Again - thank you. You made my whole day!!!

1 Like