How to change the string date into specific date format

How to change the string date into specific date format.

I want to change the string date e.g. from 26 Feb 2020 to 2020-02-24 (yyyy-MM-dd).

Can anyone please suggest the solution for this.

Hi @vaibhav2.chavan try this

date_1=“26 Feb 2020”

date_2= DateTime.ParseExact(date_1, “dd MMM yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy-MM-dd”)

Try this way

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed:

@NIVED_NAMBIAR - Thanks for reply, but i’m getting the below error, can you please have a look on it.

Hi @vaibhav2.chavan it should be Culturalnfo instead of CulturalInfo

I had corrected in my first response.

Please check

@NIVED_NAMBIAR - Still getting same error.

Culturelnfo instead of CulturalInfo

1 Like

Thanks @ppr for correction.
Sorry @vaibhav2.chavan for mistake

@NIVED_NAMBIAR/@ppr - I’m still getting the same error after correction. Please help.

sometimes it hangs in the cache:

  • take the entire statement into Clippboard (CTRL+C) and delete it
  • close expression editor
  • open expression editor and paste it back (CTRL+V)
  • close expression editor

or just do the same within a second assign and if its working delete first assign.

also take a note on:
import namespace:
grafik

and change the part to: System.Globalization. CultureInfo.InvariantCulture

1 Like

Please check this one for correction of error

@NIVED_NAMBIAR/@ppr -

After adding system.Globalization still getting same error.

Please correct the typo:

As mentioned above. After adding System.Globalization to the namespace imports you can go with the shortened name: CultureInfo.InvariantCulture

Hi @vaibhav2.chavan it should be

System.Globalization.CultureInfo.InvariantCulture

WINDOWS系统可以设置日期时间的表示格式,从/形式改为-形式

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.