2 Replies Latest reply on Jul 31, 2015 7:02 AM by philmodjunk

    Probably a simple question regarding dates



      Probably a simple question regarding dates


      Hi there

      I have a list of dates sorted from the most recent at the top to the oldest at the bottom.

      Dumb question, how can I create a sort field which calculates a number based on the date, for example:

      Date              Sort

      01/01/2015     1

      01/01/2015     1

      01/12/2014     2

      01/12/2014     2    

      31/10/2014     3

      15/10/2014     4

      As you can see, like dates have the same sort number, different and older dates take the next sort number.


        • 1. Re: Probably a simple question regarding dates

          You'll have to describe a little better what the fields represent, how did you arrive at a sort number, etc.  What exactly are you trying to do, besides sort by date?  If you just want the records listed starting with 1, you could use Get(RecordNumber), but you wouldn't be able to sort by that number. 

          • 2. Re: Probably a simple question regarding dates

            An unstored calculation can so this for small sets of records if you will keep the records in this sorted order. For larger record sets or for holding rank even with the records sorted differently, you could use Replace Field Contents with the same expression to assign the value to a number field:

            Let ( R = Get ( RecordNumber ) ;
                     Case ( R = 1 ; 1 ;
                                  GetNthRecord ( DateField ; R -1 ) = DateField ; GetNthRecord ( RankField ; R - 1 ) ; // copy same rank as previous
                                  GetNthRecord ( RankField ; R - 1 ) + 1 // assign rank of previous record's rank + 1
                                ) // Case
                   ) // Let