cancel
Showing results for 
Search instead for 
Did you mean: 

Changing poorly formatted date into a clean date

BigUrn
New Contributor

I’m working on creating a few pipelines to transform some data, but I’m having an issue with the date field. The date field I pull is a string and not a date which is the main issue. It’s formatted as MMM 'yy so as an example October 2022 would be formatted as Oct '22. I would like to transform this into an actual date field so that the data is formatted like 10/1/22 instead. The day of month isn’t relevant for this data so any number works there. I’ve been looking around the Snaplogic community, but I can’t find a method that would convert this into a date. Using something like date.parse doesn’t work since it’s not a date field and I wasn’t able to get a type converter snap to work for this. I’ve been manually fixing the dates in Excel and I would like to improve this process going forward since I need to do this monthly. Does anyone have any suggestions on how to get convert this field into a legitimate date?

1 ACCEPTED SOLUTION

bojanvelevski
Valued Contributor

I’m updating the expression:

I’ve tested this one:

Date.parse("Oct '22", "MMM ''yy")

View solution in original post

2 REPLIES 2

bojanvelevski
Valued Contributor

Hi @BigUrn,

There’s an option within the Date.parse(), to let the function know the specific format, by passing an additional argument.

If the day is not relevant, you can try something like this:

Date.parse("01 " + $date, "dd MMM 'yy")

bojanvelevski
Valued Contributor

I’m updating the expression:

I’ve tested this one:

Date.parse("Oct '22", "MMM ''yy")