Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Suggested answer

Conditional date&hour formatting

(1) ShareShare
ReportReport
Posted on by 2
Hi all.

I'm trying to use a conditional date format and post it at a sharepoint list, getting data from a microsoft forms.

i'm using this approach:
if(
    empty(outputs('Obtener_los_detalles_de_la_respuesta')?['body/r37ce541b12614e19b5a2e4f8554b9d60']),
    '9999-12-31T00:00:00Z',
    formatDateTime(outputs('Obtener_los_detalles_de_la_respuesta')?['body/r37ce541b12614e19b5a2e4f8554b9d60'], 'yyyy-MM-ddTHH:mm:ssZ')
)
inside a Create Item box that goes to a SharePoint list. The date column at list is ok and working.

If i leave only: formatDateTime(outputs(
'Obtener_los_detalles_de_la_respuesta')?['body/r37ce541b12614e19b5a2e4f8554b9d60'], 
'yyyy-MM-ddTHH:mm:ssZ'
it works ok as long as i get a non blank date at the forms that captures the data.

Using a compose action before the create action and sending me the results the process works ok, giving me the correct results in each case.
The problem has to be at the Create Item box.

I will use some other date fields at Create Items box that will need the same type of expression to get other dates from the form.

Error:
Unable to process template language expressions in action 'Crear_elemento' inputs at line '0' and column '0': 'In function 'formatDateTime', the value provided for date time string '' was not valid.
The datetime string must match ISO 8601 format.'.


Thank you in advance.
  • Suggested answer
    Michael E. Gernaey Profile Picture
    43,399 Super User 2025 Season 1 on at
    Conditional date&hour formatting
    Hi
     
    pretty please, give the issue you are having first, it doesn't help to read all the stuff, then do and this causes me this issue, as we weren't looking for issues
    we were just reading the code :-)
     
    I am sorry, I am not following what you are saying at all.
     
    You said the code you first listed works, so I dont understand why  you aren't using that then?
     
    So I am not even sure what the issue is, where it is, and what code you have that's causing it as you have so much just stuff. Please make it more clear by simplifying, without making suggestions.
  • Suggested answer
    CA1105 Profile Picture
    513 on at
    Conditional date&hour formatting
     
    There is date range which SharePoint follows i.e.
     
    Min Date selection allowed: 1/1/1900 
    Max Date selection allowed: 12/31/8900
     
    Hope this helps.
  • Suggested answer
    Pstork1 Profile Picture
    66,953 Most Valuable Professional on at
    Conditional date&hour formatting
    If you try to set the date and time in SharePoint manually you will find that it has a maximum value. If you set it beyond the max or min you get the following error.

    "You must specify a valid date within the range of 1/1/1900 and 12/31/8900."

    Try changing the first value to '8900-12-31T00:00:00Z'

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492