Author Topic: Pre-Defined filter 7 days old from today  (Read 1491 times)

neoinbiz

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 22
    • View Profile
Pre-Defined filter 7 days old from today
« on: February 20, 2021, 01:47:41 am »
Is there a away to pre-define a filter by todays date and other date values older than 7 days from today?
« Last Edit: February 20, 2021, 01:50:39 am by neoinbiz »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Pre-Defined filter 7 days old from today
« Reply #1 on: February 22, 2021, 02:53:44 pm »
Please check this example on pre defined filters:

https://paramquery.com/pro/demos/filter_initial

And to get a date older than 7 days, use "less" filter condition with

Code: [Select]
new Date(Date.now() - 7 * 24 * 60 * 60 * 1000)

neoinbiz

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Pre-Defined filter 7 days old from today
« Reply #2 on: February 22, 2021, 07:16:06 pm »
This does give the date of 7 days older but did not pre-define the filter for the Created column.
I changed the date to be the 7 day of date of 2/15/2021
Am I missing something?

Code: [Select]

{ title: "Created", width: "8%", dataIndx: "Created",
render: function (ui) {
    if (ui.rowData.Created) {
        var usaDate = new Date(Date.now() -7 * 24 * 60 * 60 * 1000);
        return usaDate.getMonth() + 1 + "/" + usaDate.getDate() + "/" + usaDate.getFullYear();
    }
}
},

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Pre-Defined filter 7 days old from today
« Reply #3 on: February 22, 2021, 10:07:11 pm »
Please add this filter property to the column:

Code: [Select]
filter: {               
                crules: [{
                    condition: 'less',
                    value: $.datepicker.formatDate("mm/dd/yy", new Date(Date.now() - 7 * 24 * 60 * 60 * 1000))
                }]               
        }