Frequently Used Date Expressions In Pega
Hi,
In this post I will show some of the frequently used date expressions in pega. Before starting we will see some of the date subscripts used in date functions.
For Ex: If date is = 05/March/2023
yyyy = Year => 2023
YYYY => 2023
MM = Month => 03
M=> 3
MMMM ===> March
MMM ====> Mar
dd = Date/day => 05
d ===> 5
1) pxFormatDateOnly(CurrentDateTime(),"yyyyMMdd","MM/dd/yyyy")
Here,
CurrentDateTime() = 20230618T025027.005 GMT
CurrentDateTime() returns the current date and time.
pxFormatDateOnly() = Format/reformat a Date Time string using a specified parameters.
Output = 06/18/2023 { which is 18 June 2023}
2) FormatDateTime(CurrentDateTime(),"yyyyMMdd","","")
FormatDateTime = Format/Reformat a date time string using the specified parameters.
Output = 20230617
3) CurrentDateTime()
To get current date time we use above function.
Output = 20230618T030048.093 GMT
4) To Get Day/Date
@FormatDateTime(CurrentDateTime(),dd,"","")
To get Day/Date in numeric format we use above expression. Here current date is 18 June 2023
Output = 18
5) To Get Year
@FormatDateTime(CurrentDateTime(),YYYY,"","")
To get year from date we use above expression. Here, current date is 18 June 2023
Output = 2023
6) To Get Month
@FormatDateTime(CurrentDateTime(),MM,"","")
To get month in numeric format we use above expression. Here, current date is 18 June 2023.
Output = 06
7) Add Months to Date
@FormatDateTime(@addCalendar(01/21/2023,'0','3','0','0','0','0','0'),MMMM,"","")
Here, we are adding 3 months to current date which is 21 JAN 2023.
Output = March
8) Add Months to Date
@FormatDateTime(@addCalendar(01/21/2023,'0','3','0','0','0','0','0'),MM,"","")
Output = 03
9) Add Days to Date
@(Pega-RULES:BusinessCalendar).addDays("20230125",10,false,"")
Here, we are adding 10 days to current date which is 25 JAN 2023.
Output = 20230204
10) getCurrentDateStamp()
Return type of getCurrentDateStamp() is String. Get the current date in Pega format (yyyyMMdd)
Output = 20231201
Comments
Post a Comment