How to convert string to date in pega?

I am getting all the dates from data page in dropdown. But dates are displaying as text 20220808, I want to display this string as date, In format MM/dd/yyyy

@AbhishekC1725 Hi, use this expression

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

@AkshithReddyT thanks, Already tried this expression but not working

Hi @AbhishekC1725,

Have you tried to format the control to Date/Time in the Presentation Tab?

@AbhishekC1725 Hi Abhishek, you have mentioned about the data page but did not mention the source of DP. Assuming that it is a report definition. There is a option that you can use in the data page as a response data transform. Use the DT to loop over the results from the report. Use the function @DateTime.FormatDateTime(.pxCreateDateTime,“MM/dd/YYYY”,null,null) to convert into required format (07/04/2022) in the loop.

If the source is a data transform/activity, you can do the same logic in this also. It will work.

@MaheshN29 Thanks Mahesh, I followed the same steps and it worked thanks