0

There is a date field in my logic app which i am getting data from finops connector. enter image description here

In JSON assigning the field. After Parsing Json and create a csv table assinging like this enter image description here

Is there a way for me to format the date using formatDateTime in any of the steps above ?

Thanks, Vivek

  • So you know the expression, have you had a go? You can use the expression anywhere you can use the pill. – Skin Jan 26 '23 at 08:30
  • Yes I know the expression but in the expression i cannot reference the Date filed above. – Vivek Chirumammila Jan 26 '23 at 08:57
  • Help me understand why not though. You should be able to. – Skin Jan 26 '23 at 08:59
  • I am getting this error In function 'formatDateTime', the value provided for date time string '' was not valid. The datetime string must match ISO 8601 format.'. – Vivek Chirumammila Jan 26 '23 at 09:18
  • Ok, so can you show us the value of that field? It’ll be in the log somewhere. – Skin Jan 26 '23 at 09:19
  • The Input date looks like this 2022-10-18T12:00:00Z – Vivek Chirumammila Jan 26 '23 at 09:35
  • It should format, can you show us the expression you use to format the date? – Skin Jan 26 '23 at 09:41
  • formatDateTime(item()['InvoiceDate'],'dd.MM.YYYY') – Vivek Chirumammila Jan 26 '23 at 09:45
  • Bizarre, if you've given me the correct value for the `InvoiceDate` when it goes in, it works for me, also, you need to use `dd.MM.yyyy` (small y's) to get the year. Just thinking though, have you checked all `InvoiceDate`'s in your array? Are any of them null? – Skin Jan 26 '23 at 09:49
  • Now that you mention it I am looking from one record perspective and in array i have some null values which i have joined from multiple sources and places a common csv structure. Do you have any idea what to be passed instead on empty string in remaining InvoiceDate – Vivek Chirumammila Jan 26 '23 at 09:53
  • Well ... that's really a decision for yourself. Take LogicApps out of it, what would you do with the data where the invoice date is null? – Skin Jan 26 '23 at 09:56
  • Thank you very much I might have been struck there looking from wrong prespective – Vivek Chirumammila Jan 26 '23 at 09:57

1 Answers1

2

I suspect you may have an issue with null values in your array.

You need to check every item and make sure the invoiceDate field contains a valid value.

Something like this will help you if you don't filter them out ...

if(equals(item()['invoiceDate'],null),'',formatDateTime(item()['invoiceDate'], 'dd.MM.yyyy'))

... but you will need to decide on the business logic with those items that do have a null invoice date.

Skin
  • 9,085
  • 2
  • 13
  • 29