The Community will be temporarily unavailable starting on Friday February 28. We’ll be back as soon as we can! To learn more, check out our Announcements blog post.
Jun 07, 2020 09:35 AM
I’m trying to format a bunch of date ranges to be used in WORKDAY().
I created a script that collects these dates from a base and have them converted to iso-dates.
However all my dates has a trailing time stamp of T00:00:00.000Z.
Wondering if there is a quick way to omit of the time stamp so it’s only YYYY-MM-DD?
Solved! Go to Solution.
Jun 07, 2020 03:37 PM
Well, there are as many ways to do this as there are to compute your personal tax liability, but… I’m lazy so when dealing with predictable strings - like an ISO date - I just do this:
Given this:
let isoDate = "2016-05-24T15:31:48.335Z";
I would simply:
let dateOnly = isoDate.split("T")[0];
Javascript experts would probably spit on my grave for suggesting this. But in a sanitized environment like Script Blocks, I’m not actually sure what level of date formatting support exists.
Jun 07, 2020 03:37 PM
Well, there are as many ways to do this as there are to compute your personal tax liability, but… I’m lazy so when dealing with predictable strings - like an ISO date - I just do this:
Given this:
let isoDate = "2016-05-24T15:31:48.335Z";
I would simply:
let dateOnly = isoDate.split("T")[0];
Javascript experts would probably spit on my grave for suggesting this. But in a sanitized environment like Script Blocks, I’m not actually sure what level of date formatting support exists.
Jun 08, 2020 01:35 AM
@Bill.French Thank you for this.
I’m all for being lazy and I thought there would be a ‘dirty’ simple way to do this without involving splitting the date into subpart and putting them together again, or trying to hack together some regEx.
Just a bit ashamed I didn’t see this solution myself.
Thanks again