
OK, so I can do it, but it's dirty, and feels wrong.
Basically, take the example of me having an array field that I need to use in a filter, and the date may simply be formatted as:
1983.
The formatDateTime function does not accept this. If it has Jan, January, or literally any other demarcation of a date around it, we are good, but a year on its own? Nope.
To make things simpler for working this out, let's just assume I have a variable called year, and that contains either something like March 1983, or just 1983.
Here's what I'm currently using ... and be forewarned ... it's a mess.
formatDateTime(if(and(contains('1234567890', substring(variables('year'), 0, 1)), equals(length(variables('year')), 4)), concat(variables('year'), '-01-01T00:00:00.0000000'), variables('year')))
So, with the above:
Let's ignore the fact that I could drop the formatDateTime from the above and still probably get something workable (the real world usage is to filter array items on this date field, so I want to be sure) ...
... is there a simpler function to illicit proper date data from just a YYYY value?
I mean, I need to know that externally of any context. If there is a 4 number string, is there a way of seeing that as a date in flow?
Hi @eliotcole :
ISO 8601 Data elements and interchange formats – Information interchange – Representation of dates and times is an international standard covering the exchange of date- and time-related data.In view of the fact that power automate does not provide the function of directly and automatically converting the "year" in the form of a string to the date at 0:00 on the 1st of January of the current year, in the steps you provide, add'-01-01T00:00 to the "year" :00.0000000' is a necessary operation to comply with the ISO 8601 format.
Best Regards,
Bof