create a Date from year month day or big decimal

How to create a Date (or DateTime) from year month day or big decimal in Pega?

E.g. I have 3 integers, 2022, 10, 03, I need create a Date 2022Oct03, how to do it?

Another option, I get a BigDecimal from function date(year, month, day), then how can I create a Date (or DateTime) from the BigDecimal?

Pls note I would like to use Pega OOTB functions only, instead of write Java codes.

Hi @MaxonL16591286, do you really want “Oct” in your final result or is it just for explaining? Asking this because having “Oct” will make it a non pega date.

To simply achieve date from string you can use: @DateTime.addToDate(“Param.YourDate”,“”,“”,“”,“”) just make sure to concatenate the three integers into a param and pass the param onto your function.

@MaxonL16591286

Hello,

Can you try the following:

@DateTime.FormatDateTime(@addToDate(“19700101”,@round(@date(2022,10,03)),‘0’,‘0’,‘0’),YYYYMMMdd,“GMT”,null)


@date(2022,10,03) - 19268.0
@round(@date(2022,10,03)) - 19268
@addToDate(“19700101”,@round(@date(2022,10,03)),‘0’,‘0’,‘0’) - 20221003T000000.000 GMT
@DateTime.FormatDateTime(@addToDate(“19700101”,@round(@date(2022,10,03)),‘0’,‘0’,‘0’),YYYYMMMdd,“GMT”,null) - 2022Oct03

@SaurabhG7134

“Oct” is it just for explaining, i need build a day into a property of type Date or DateTime in Pega, with my specified year, month day.

addToDate function is to add days based on an existing date.

I’d like to build a day myself from scratch.

@kalls4

many thanks. Let me try. As I need a value put in Date / DateTime property, no need format, so I will test below only:

@addToDate(“19700101”,@round(@date(2022,10,03)),‘0’,‘0’,‘0’)