Hi Friends,
Can someone help me to find the least date and max date from a given list of dates.
Thanks
Vani
Discussion posts and replies are publicly visible
Hi Geervanim,
use sorttextarray function is help out your requirement
find below code snippets.
local!computedDates: union(local!dates,local!dates), local!sortAscending:sorttextarray(touniformstring(local!computedDates),0), local!dateAsc: if(rule!APN_isBlank(local!sortAscending),{},todate(local!sortAscending[1])), local!sortDescending:sorttextarray(touniformstring(local!computedDates),1), local!dateDesc: if(rule!APN_isBlank(local!sortDescending),{},todate(local!sortDescending[1])),
hope this is help
Regards,
Bhanu
Hope the below expression gives some thoughts:
with( local!dates: { today(), today() - 3, today() + 5, today() - 1 }, "Least date: " & todate( min( tointeger( local!dates ) ) ) & char( 10 ) & "Max date: " & todate( max( tointeger( local!dates ) ) ) )
You can also use the sorting capability in a datasubset. Here's an example:
a!localVariables( local!listOfDates: { {id: 1, date: now()+1}, {id: 2, date: now()+11}, {id: 3, date: now()-2} }, /*local!listOfDates.date*/ local!sortedDates: fn!todatasubset( local!listOfDates, a!pagingInfo( startIndex: 1, batchSize: -1, sort: a!sortInfo( field: "date", ascending: false ) ) ), local!sortedDates.data )
If you run this, and then change the 'ascending' attribute to 'true' and then run it again you'll see the order is reversed.
Hello Vani,
Please follow the suggestion from vimalkumars.
At the end the dates in appian are integers (just date) decimal (date:time) So try the functions min and max
todate(min(local!dates))todate(max(local!dates))
Hope this helps
Jose
Ohh it was here before