Posted: 14 Aug 2017 8:49 EDT Last activity: 16 Aug 2017 5:46 EDT
How to set current date time to Beginning or End of the day
We have two DateTime properties "Start Date" and "End Date"
To set Default value of "Start Date" and "End Date" as current date we are using function @(Pega-RULES:DateTime).CurrentDateTime(). While checking the property on the clipboard it is displaying as 20170814T122032.036 GMT. It is understood as it is setting the current Hours and current Minutes.
According to our requirement we want Default value of "Start Date" to be set to Beginning of day ie 20170813T000000.000 GMT and "End Date" to be set to end of the day ie 20170814T235900.000 GMT.
Is there a way to achieve this by doing changes directly in the property?
We are using Date Time because we are concerned with the Time also as I mentioned we need the StartDate to be set to start of current day that is 00:01 AM and End Date to be set to End of current Date i.e 11:59 PM. Also DateTime is used throughout our application.
You can write logic something like below to initialize the values.
Param.CurrentDate = @(Pega-RULES:DateTime).CurrentDateTime()
Define Param.CurrentDate as Date property.
StartDateTime = Param.CurrentDate + "T000000.000 GMT"
EndDateTime = Param.CurrentDate + "T235900.000 GMT"
To my knowledge you can't implement this initialization with some configuration within property definition itself.
One way is if StartDate and EndDate properties are part of your case you can initialize these values using some DataTransform at the time of case creation.
Hope this helps.