How do I Filter Views based on Date Criteria?

How do I Filter Views based on Date Criteria?

Show records that expires in the next seven days

You can use the following criteria in your view to fetch records ending in the next 7 days, based on the Expiry date in the form. In the sample code given below, Expiry is the name of the date field in the Sample form which stores the date on which a record expires. To add the criteria to the view definition, select the required view from the Script tab.

list  "Sample View"
{
show all rows from Sample [(Expiry <= (zoho.currentdate + '1W:0D:0H:0M:0S')
&& Expiry >= zoho.currentdate)]

(
Expiry
)

}

Show records started in the last two weeks

Assume you have a form named Sample with a date field that captures the StartDate of a project. To display the records started before 2 weeks, you can add the following criteria to the view in script mode:

list  "Sample View"
{
show all rows from Sample
[StartDate > (zoho.currentdate - '2W')]
(
StartDate
.....
)

}

In the above statement, zoho.currentdate returns the current date and 'W' stands for week. Refer the topic Operators in Deluge Scripting , for more information on the date & time operators.

Show records started on the current date

Assume you have a form named Sample with field StartDate. If you want to view all the records whose StartDate is the current date, you can create a filter using the zoho.currentdate function, as shown below:

list  "Sample View"
{
show all rows from Sample
[StartDate == zoho.currentdate]
(
StartDate
.....
)

}

Show records related to the current week

Assume you have a Date field in your Form called Date_1 which stores the date when the Employees enter their TimeSheet. Add another field to your Form say DateInfo to store the week and the year of the date. This is achieved by writing On User Input script to the Date_1 field, as given below.

To update the DateInfo field with the week and year of the Date_1 field, write

//to get the week and year entered in the form and update it in the Dateinfo field

input.Dateinfo = (((input.Date_1.getWeekOfYear())) + "") + (input.Date_1.getYear());

In the view, specify the criteria as given below.

list  "Sample View"
{
 //to get the current week and year and compare it to the date entered in the form
show all rows from Sample
[DateInfo == (((zoho.currentdate.getWeekOfYear())) + "")
+ (zoho.currentdate.getYear())]

(
Name
.....
)

}

    • Related Articles

    • Managing List Views

      A List View is grouping of records based on a defined set of criteria. List Views are beneficial for displaying customer specific data according to your business requirements. For example, you may be interested in following-up on the candidates ...
    • Manage List Views

      A List View is grouping of records based on a defined set of criteria. List Views are beneficial for displaying specific data according to your business requirements. For example, you may be interested to review overdue tasks or you may want to ...
    • Managing List Views

      A List View is grouping of records based on a defined set of criteria. List Views are beneficial for displaying customer specific data according to your business requirements. For example, you may be interested in following-up on the leads created ...
    • Date-field Autoresponder

      Understanding date-field autoresponder Date-field based autoresponders are a series of automated messages that are sent to contacts based on the date in the date field associated with them. Wishing customers happy birthdays and anniversaries are ...
    • How to filter timesheet based on date and user?

      You can filter your timesheet date-wise and user-wise. Learn more to know, how you can group timesheet by user and date.