Convert Datetime to YYYYMMDD issue: day is incorrect

.SelectedDeadlineDateTime is in type DateTime

I use this function to convert it to YYYYMMDD,

@(Pega-RULES:DateTime).FormatDateTime(.SelectedDeadlineDateTime,“YYYYMMDD”,null,null)

However, it returns incorrect DD once the date after 31Jan, e.g. as below sample. It should be a julian date. I expect 20230201. May I know how could I get this date string? thanks.

@MaxonL16591286 Hi I tried YYYYMMdd is fine, thanks.

Any better solution, pls advise.

@MaxonL16591286 If this is just for display purpose, then you can use substring function and form your date accordingly and then use that string to display.

@MaxonL16591286 Hi, Can you please try the below function?

@DateTime.FormatDateTime(@DateTime.CurrentDateTime(),“yyyyMMdd”,“”,“”)

Please add timezone and Locale according to your requirement.