Convert Date to YYQ# Using moment.js in Podio Calculation Fields

This post will go over some useful date formatting techniques, using moment.js. Moment.js is a great JavaScript framework that is supported in Podio calculation fields and is used specifically for date formatting!

Here’s an example of a calculation we did for client #L-0395:
We started with a date field titled, “Proposed Launch Date” The client wanted to reformat this field in a separate calculation field to show only the year and quarter, so it would look like this: YYQ#

Using moment.js, this becomes a much easier task. Check it out:

moment(Proposed Launch Date).format('YY') + "Q" + moment(Proposed Launch Date).quarter();

As you can see, in the first half, moment pulls in the date and formats it as just YY, ie. 2015 becomes 15. Next we add “Q” in a string. Then in the last part, moment grabs the date and spits out a quarter, which is 1-4, ie. October = 4, January = 1, etc. So if we put October 10th 2015 in the date field, it spits out: 15Q4.

If you want to try other date formats, check out moment.js, they have some great ways to format dates! Or you can contact us for more in-depth help with advanced calculation fields!

Check back Wednesday every week for more Podio Tips & Tricks!