Changing Date from string to Date format
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi All,
I have dates in my data in the following two formats: yyyy-mm-dd and dd/mm/yyyy. They are in the same column and data type is string.
I want to change both of these into dd-mm-yyyy format.
I tried using formula tool but that omits one of the above formats and gives null for those. DateTime tool is also not giving the required result.
How to do it in a simple way so that dates in both the above formats change to the required format and don't give null values?
Solved! Go to Solution.
- Labels:
- Date Time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @Dheeru28 you will need to parse your dates twice given you have two formats. You could wrap this in a conditonal statement first testting for the format then parsing it. I have mocked up an approach which showcases one way to tackle this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
hey @Dheeru28 you could use this expression:
IIF(Contains([Date], '/'),
DateTimeFormat(DateTimeParse([Date], '%d/%m/%Y'), '%d-%m-%Y'),
DateTimeFormat(DateTimeParse([Date], '%Y-%m-%d'), '%d-%m-%Y'))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I have dates in my data in the following two formats: yyyy-mm-dd and dd/mm/yyyy. If the formats yyyy-mm-dd and dd/mm/yyyy is the only formats , u just need the tool DateTime in Parse 。
Choose String to Date/Time format
It will be done easily.
