Error : string is not recognised as valid date time format

Hi all,

How to solve the “Assign: The string was not recognized as a valid DateTime.” Error.
I am reading a date time from a json in this format
Date “:“2021-08-31T00:00:00.000Z”
But when i add it in write line like “Date”+date, the output is displayed as 208/31/2021 00:00:00”

How can i solve this error? and how can i knwo which is the correct format.
Please help!

@pooja.pakanati

Check below for your reference

Reference

Hope this may help you

Thanks

What are you trying to do ? I.e. reading this value and planning to convert it to different format?? if so what is the output format you wanted to covert??

I want to convert it to Date time of format (“MM/dd/yyyy”) so that i can check if the date is greater than DateTime.Now.

Hi @pooja.pakanati

Try to use

Date Format : DateTime.Now.ToString(“MM/dd/yyyy”)

Regards
Gokul

@pooja.pakanati - please check this…

image

Datetimes don’t have a format. “MM/dd/yyyy” is a string format. What you want to do is use Parse to convert the string “2021-08-31T00:00:00.000Z” into a Datetime, so you can compare it with other datetimes.