cancel
Showing results for 
Search instead for 
Did you mean: 

Date format

SOLVED
Dhilip_Kumar
Asteroid

Date format

We received dates format as "mm/dd/yyyy or yyyy/dd/mm" so I need to change date format to mm/dd/yyyy if we received both format. I used if formula but its not working.

 

If DateTimeParse([Date],'%Y/%m/%d') then Datetimeformat(DateTimeParse([Date],'%Y/%m/%d'),"%m/%d/%Y") else [Date] endif

 

Please do the needful.

3 REPLIES 3
Dhilip_Kumar
Asteroid

Date format

We received dates format as "mm/dd/yyyy or yyyy/dd/mm" so I need to change date format to mm/dd/yyyy if we received both format. I used if formula but its not working.

 

If DateTimeParse([Date],'%Y/%m/%d') then Datetimeformat(DateTimeParse([Date],'%Y/%m/%d'),"%m/%d/%Y") else [Date] endif

 

Please do the needful.

ShankerV
Castor

Re: Date format

Hi @Dhilip_Kumar 

 

Please use the below formula.

 

IF REGEX_Match(Left([Field1],4),"\d{4}")
THEN datetimeformat(DateTimeParse([Field1],'%y/%d/%m'),"%m/%d/%Y")
ELSE [Field1]
ENDIF

 

Screenshot 2023-08-18 155456.jpg

Many thanks

Shanker V

DataNath
17 - Castor

Re: Date format

Hey @Dhilip_Kumar, you can adjust your current formula very slightly by wrapping the initial if check in an !isnull() - and swapping the %d and %m you had the wrong way round to get the outcome you're after. For the yyyy/dd/mm records, they won't be null and so it'll do the conversion. For records already in the desired format, they'll be left as is! That looks like this:

 

If !IsNull(DateTimeParse([Date],'%Y/%d/%m')) then Datetimeformat(DateTimeParse([Date],'%Y/%d/%m'),"%m/%d/%Y") else [Date] endif

 

Re: Date format

Thanks you so much. It's works!!!!!! Much Appreciated