Convert date format to from 2023-05-17 15:02:22 to dd/MM/YYYY

Hello,

I wish to convert date from 2023-05-17 15:02:22 to dd/MM/YYYY format.

I have already tried using the @DateTime.FormatDateTime(.modifiedDateTime,“DD/MM/YYYY”,null,null) but it didn’t work must be because .modifiedDateTime = 2023-05-17 15:02:22.

When I tried with CurrentDateTime it worked because the result is 20230526T053128.077 GMT.

I also tried to convert 2023-05-17 15:02:22 to 20230517150222 by using @String.replaceAll(@String.replaceAll(@String.replaceAll(“2023-05-17 15:02:22”,“-”,“”),“:”,“”), " ", “”) and it also didn’t work.

Can someone help please?

Thanks

@PratimaK16730164 This seem to be working

@DateTime.FormatDateTime(@String.replaceAll(pxReplaceAllViaRegex(“2023-05-17 15:02:22”,“[-:]”,“”)," “,“T”)+”.000 GMT",“dd/MM/yyyy”,“”,“”)

Hi @PratimaK16730164!

Please try this.

@DateTime.FormatDateTime(@DateTime.CurrentDateTime(),“dd/MM/yyyy”,“”,“”)

@PratimaK16730164

Since you don’t need timestamp to convert the date to a specific format, follow these steps

  1. Use function @whatcomesbeforefirst(“2023-05-17 15:02:22”,’ '); to get only the date stamp.

  2. Input the date stamp returned from step1 to @replaceAll(“2023-05-17”,“-”,“”);

  3. Map the output from line 2 to a parameter (param.output) of type DateTime, this will convert your date value to a propert GMT timestamp.

  4. Use the parameter mapped in step3 in the following function @DateTime.FormatDateTime(param.output,“dd/MM/yyyy”,“”,“”);

Hope this helps!

@BhanuPrakash_G

Thanks for you help

Hi @BhanuPrakash_G

Your functions works exactly as required, but when I tried to pass a paramter in place of the hardcoded datetime value, could get no return value. Is there a way to achieve passing the same by use of a parameter or property?