Hi @Ananya Dixith ,
I would need to know the value you are passing, I see you are using compose. you may need to add some cast script overthere like:
https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#parsedatetime
without that I get the same error passing something like a date in another language
for the error above I passed this value
and fixed with this script. If you can share your date format I can suggest a script
If your date has an unusual format you may need to split the parts, reassemble in a way the "formatDateTime" would understand
On your case "21-09-12" you need to split in 3 parts using the "-" as a delimiter:
formatDateTime(concat(split(triggerBody()?['date'], '-')2,'-',split(triggerBody()?['date'], '-')1,'-',split(triggerBody()?['date'], '-')[0]),'yyyy-MM-ddTHH:mm:ssZ')
you can try to paste this into your compose:
formatDateTime(concat(split(triggerBody()?['date'], '-')[2],'-',split(triggerBody()?['date'], '-')[1],'-',split(triggerBody()?['date'], '-')[0]),'yyyy-MM-ddTHH:mm:ssZ')
if it doesn't work straight away, try assembling it bit by bit
starting with: split(triggerBody()?['date'], '-')2
replace the triggerBody()?['date'] with your field, you can open a compose, switch to expression, enter split and fill the parameters until you manage to get that right
your date has 3 parts separated by a dash "-"
with a [0] in the split function, you get the first part of your date, the 21 in 21-09-12
split(YOURINPUTDATEHERE, '-')[0]
than add the concat('string1','string2','string3'), remembering you need to re-add the dashes and rearrange the parts to 2-1-0
concat(split(YOURINPUTDATEHERE, '-')2,'-',split(YOURINPUTDATEHERE, '-')1,'-',split(YOURINPUTDATEHERE, '-')[0])
and finally the formatDateTime: formatDateTime("string value here",'yyyy-MM-ddTHH:mm:ssZ')
formatDateTime(concat(split(YOURINPUTDATEHERE, '-')2,'-',split((YOURINPUTDATEHERE, , '-')1,'-',split((YOURINPUTDATEHERE, , '-')[0]),'yyyy-MM-ddTHH:mm:ssZ')
result:
Hi @Ananya Dixith , I've added the rest of the answer on the bottom of my first answer. try this expression formatDateTime(concat(split(triggerBody()?['date'], '-')[2],'-',split(triggerBody()?['date'], '-')[1],'-',split(triggerBody()?['date'], '-')[0]),'yyyy-MM-ddTHH:mm:ssZ')
Hi @Ananya Dixith ,
Have you managed to try that expression. Let me know if you need further help. I can send a video/gif on how to apply that. If the post helps, could you accept the answer?