I have a flow which is coming from power app click button, It bring the Json data, So I am select data operation method to apply the column with some formatting, All is working fine but Date format function is producing error.
Could not understand the mistake in the expression below
Below is the images of my flow, error and its related screen
My Flow:
The execution of template action 'Select_Data_Method' failed: The evaluation of 'query' action 'where' expression '{
"Record No": "@item()?['RecoNo']",
"Svc Date": "@formatDateTime(item()?['SvcDate'],'MMM/dd/yyyy')",
"Model": "@item()?['Model']",
"Serial No": "@item()?['SerialNo']",
"Svc SMR": "@item()?['SvcSMR']",
"Svc Remarks": "@item()?['SvcRemarks']",
"Svc Expense": "@formatNumber(item()?['SvcExpense'],'0.00')",
"Customer": "@item()?['Customer']"
}' failed: 'In function 'formatDateTime', the value provided for date time string '26-01-2024' was not valid. The datetime string must match ISO 8601 format.'.
Pls try this one, I have added check for null or empty values in the expression:
if(empty(item()?['SvcDate']),'',formatDatetime(concat(last(split(item()?['SvcDate'],'-')),'-',join(take(skip(reverse(split(item()?['SvcDate'],'-')),1),2),'-')),'MMM/dd/yyyy'))
If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.
Pls try this one, I have added check for null or empty values in the expression:
if(empty(item()?['SvcDate']),'',formatDatetime(concat(last(split(item()?['SvcDate'],'-')),'-',join(take(skip(reverse(split(item()?['SvcDate'],'-')),1),2),'-')),'MMM/dd/yyyy'))
If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.
I tried your advise expression (copied and pasted in the expression, the flow failed, below is the failed detail result.
Kindly check and advise
@MIA27 - I think you will need to reformat the DateString -See solution below:
Expressions:
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
P.S. take a look at my blog here and like & subscribe to my YouTube Channel thanks.
Hi @MIA27
Function formatDatetime accepts date in ISO format (yyyy-MM-dd) but the input date is not in that format. You can try below expression, assuming input date is always return as 'dd-MM-yyyy'
formatDatetime(concat(last(split(item()?['SvcDate'],'-')),'-',join(take(skip(reverse(split(item()?['SvcDate'],'-')),1),2),'-')),'MMM/dd/yyyy')
If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.
Hi @MIA27 !
Could you try to use this function instead ?
"Svc Date": "@formatDateTime(item()?['SvcDate'],'dd/MM/yyyy')",
Let me know if it helps.
T
Michael E. Gernaey
566
Super User 2025 Season 1
David_MA
516
Super User 2025 Season 1
stampcoin
492