Question
Anthem
US
Last activity: 26 Aug 2019 8:16 EDT
How to find the shortest datetime in a pagelist
Hi All,
I need to find the shortest date in a pagelist. For example, following is my pagelist
pg(1).Date= April 10, 2019
pg(2).Date= April 25, 2019
pg(3).Date= April 5, 2019
I need to find the index of page with April 5, 2019.
Any help or direction is much appreciated.
Thanks in advance.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Anthem
US
Thank you Sreepriya for the screenshots.
I decided to take a different route, following is what i did to solve my problem.
I sorted the page list using "Obj-Sort" on the datetime property in descending order and the 1st page has the shortest date and i am picking up both date and index from the 1st page after sorting.
Pegasystems Inc.
US
You can try to use "CompareDates" function.
It compares two DateTime strings [you need to convert your datetime in string format] and return true if the first date argument is after the second.
Example:
CompareDates("20090109T162504.370 GMT", "20090110T182504.370 GMT") = false
Pegasystems Inc.
IN
Hi Kumar,
Create two local variables in an activity to hold the index and date property of the list having oldest date.
Loop on the pagelist and include a when condition to compare the current date and the local date property, if the current date property is smaller then set the local date property to the current value and update local index value to current pagelist index using param.pyForEachCount property.Else exit the iteration.
Param.pyForEachCount holds the current index of the pagelist.
Hope it helps.
Thanks.
Anthem
US
Hi Sreepriya,
If we implement your logic, the current date will always be smaller and the output will be current date only because all 3 dates in list are future dates.
I need a function or way to find the earliest date in 3 datetime values.
Appreciate the response.
Pegasystems Inc.
IN
Hi Kumar,
'Current' word I was referring to date property value for the current pagelist index, not currentDateTime value.
I have configured a sample use case for your requirement, check the attached document for details.
Thanks.
Accepted Solution
Anthem
US
Thank you Sreepriya for the screenshots.
I decided to take a different route, following is what i did to solve my problem.
I sorted the page list using "Obj-Sort" on the datetime property in descending order and the 1st page has the shortest date and i am picking up both date and index from the 1st page after sorting.
-
Kishore Gopalakrishna
Pegasystems Inc.
US
Thanks for sharing your resolution @SKUMAR2006, I've marked your reply as the correct answer to help others who may have the same question.