How to filter date field as a user filter on record type?

Certified Associate Developer

Hi All,

I have a scenario where i need to filter the data from db based on the date. Filter values will be something like below.

Today

Yesterday

Last 7 days

FYI,

In Db,  date column is stored in date time format.

Can an someone suggest me how to achieve the filtering thing from db based on the date when db value is date time?

Thanks 

  Discussion posts and replies are publicly visible

Parents Reply Children
  • I hope this code helps you, here we are using todatetime() function to convert today value, it will add 00 hours 00 MINUITE 00 Second's that is why when filtering with Today with today()+1

    a!recordFilterList(
      name: "Created On",
      options: {
        a!recordFilterListOption(
          id: 1,
          name: "Today",
          filter: a!queryFilter(
            field:'recordType!{b99dab82-8523-47ef-a91c-20d9b66ea668}PYEOS Candidate.fields.{103f0940-5ec7-44dc-8cf8-605b30db2fb7}createdon',
            operator: "between",
            value:  { todatetime(today()),todatetime(today()+1)}
          )
        ),
        a!recordFilterListOption(
          id: 2,
          name: "Yesteday",
          filter: a!queryFilter(
            field: 'recordType!{b99dab82-8523-47ef-a91c-20d9b66ea668}PYEOS Candidate.fields.{103f0940-5ec7-44dc-8cf8-605b30db2fb7}createdon',
            operator: "between",
            value:  { todatetime(today()-1),todatetime(today())}
          )
        ),
        a!recordFilterListOption(
          id: 2,
          name: "Last 7 Days",
          filter: a!queryFilter(
            field:'recordType!{b99dab82-8523-47ef-a91c-20d9b66ea668}PYEOS Candidate.fields.{103f0940-5ec7-44dc-8cf8-605b30db2fb7}createdon',
            operator: "between",
            value:  { todatetime(today()-7),todatetime(today())}
          )
        )
      },
      defaultOption: "Active",
      isVisible: true,
      allowMultipleSelections: true
    )

  • 0
    Certified Associate Developer
    in reply to Geetha Satya Sree

    Hii Geetha Satya Sree

    Thank u so much its working fine