Skip to main content
Solved

Strip the year out of a date in a Transform task

  • December 6, 2018
  • 10 replies
  • 91 views

ben
Forum|alt.badge.img
  • Helper ⭐️⭐️⭐️
Hey folks!

I am looking for a way to strip just the year out of a date when performing a Transformation task in a query builder. i.e. If the date is 1/1/2014 I'd like the transform task to output "2014".

The reasoning is a cool holiday e-card for our large, long standing customers. We want to show them where they were when they started (seat count, etc.), their growth over that time (current - initial seats), along with the billboard top song, top grossing movie, and Apple released in that year (were an Apple software company).

Any thoughts?

Thanks!

Best answer by ankit_jain

If the objective is to send e-cards, I am hoping that you are using Journey Orchestrator and Email. In the Email Templates, you can map Show Fields of data type DATE and format values. One such option JO offers to format a date to just YYYY.

Ref: https://support.gainsight.com/Journey_Orchestrator_and_Email/Standard_Outreaches/03_Create_CoPilot_Email_Templates#Supported_Number_and_Date_Formats_for_Tokens



10 replies

john_apple
Forum|alt.badge.img+5
  • Expert ⭐️
  • December 6, 2018
Substring would work if the field were a string field and take the last 4 characters.

If it is a Date, then possible Case Expression:

If Date is less than 12/31/2018 and greater than or equal to 1/1/2018 then output number is 2018, and so on for each year.


dstokowski
Forum|alt.badge.img+5
  • Gainsight Employee ⭐️⭐️
  • December 6, 2018
Ben _ I have not tried this yet - and it is an extra step - but adding to John's comment - do a task to map the date field to a text field in your output file and then use the substring function.


samantha_braastad
Forum|alt.badge.img+1
  • Contributor ⭐️⭐️⭐️⭐️⭐️
  • December 6, 2018
I still think this would be a good add to better allow for YOY review of data. Expanding this to include both year and month from a date. This would allow you to group a metrics in reports by year and month to compare, for example, November 2018 to November 2017.


dan_ahrens
Forum|alt.badge.img+2
  • Expert ⭐️⭐️⭐️
  • December 6, 2018
As John mentioned, the secret is a case expression:




john_apple
Forum|alt.badge.img+5
  • Expert ⭐️
  • December 12, 2018
Hey Denise - could you provide more detail on "map the date field to a text field in your output file"? Do you mean within Journey Orchestrator Participant Mapping or a transformation task within the query? Or something else?


dstokowski
Forum|alt.badge.img+5
  • Gainsight Employee ⭐️⭐️
  • December 12, 2018
John - I was referring to the Transform task in Rules - just mapping from one field that is a date to a target that is a text


john_apple
Forum|alt.badge.img+5
  • Expert ⭐️
  • December 13, 2018
Hi Denise - I'm struggling to figure out the formula field that would be used for changing a date to a string. I have a similar to need to change a string value to a numeric value, is this possible?


ankit_jain
  • Helper ⭐️⭐️⭐️
  • December 27, 2018
This may be handy only if the data range is just a handful of years.

Also, if such rule has to be scheduled, it needs revision to CASE every year.


ankit_jain
  • Helper ⭐️⭐️⭐️
  • Answer
  • December 27, 2018
If the objective is to send e-cards, I am hoping that you are using Journey Orchestrator and Email. In the Email Templates, you can map Show Fields of data type DATE and format values. One such option JO offers to format a date to just YYYY.

Ref: https://support.gainsight.com/Journey_Orchestrator_and_Email/Standard_Outreaches/03_Create_CoPilot_Email_Templates#Supported_Number_and_Date_Formats_for_Tokens




ben
Forum|alt.badge.img
  • Author
  • Helper ⭐️⭐️⭐️
  • December 27, 2018
Thanks Ankit. I actually need the year for the Variant filter. I am going to see if there is something I can do in the query.