need a function to sort a cdt by a date/time field. Is there such a function to

need a function to sort a cdt by a date/time field. Is there such a function to do that? ...

OriginalPostID-88128

OriginalPostID-88128

  Discussion posts and replies are publicly visible

Parents
  • Use a!todatasubset() and specify the sort information in the a!pagingInfo()

    load(
      local!data: {
        {
          id: 1,
          date: now()
        },
        {
          id: 2,
          /* now() minus 2 hrs */
          date: todatetime(now() - (2/24))
        },
        {
          id: 3,
          /* now() minus 24 hrs */
          date: todatetime(now() - (24/24))
        },
        {
          id: 4,
          /* now() minus 72 hrs (3 days) */
          date: todatetime(now() - (72/24))
        }
      },
      local!pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: -1,
        sort: a!sortInfo(
          field: "date",
          /* Change to true of false */
          ascending: false
        )
      ),
      local!sortedData: todatasubset(
        arrayToPage: local!data,
        pagingConfiguration: local!pagingInfo
      ).data,
      /* Show results */
      local!sortedData
    )

Reply
  • Use a!todatasubset() and specify the sort information in the a!pagingInfo()

    load(
      local!data: {
        {
          id: 1,
          date: now()
        },
        {
          id: 2,
          /* now() minus 2 hrs */
          date: todatetime(now() - (2/24))
        },
        {
          id: 3,
          /* now() minus 24 hrs */
          date: todatetime(now() - (24/24))
        },
        {
          id: 4,
          /* now() minus 72 hrs (3 days) */
          date: todatetime(now() - (72/24))
        }
      },
      local!pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: -1,
        sort: a!sortInfo(
          field: "date",
          /* Change to true of false */
          ascending: false
        )
      ),
      local!sortedData: todatasubset(
        arrayToPage: local!data,
        pagingConfiguration: local!pagingInfo
      ).data,
      /* Show results */
      local!sortedData
    )

Children
No Data