Query data based on start time and end time

  • Last update:  2021-10-24
  • I. Overview

    1) Expected effect

    If there is a column of date-type data in the database, and you want to query the data of a certain period of time, how to implement this?

    5.jpg

    1.2 Implementation roadmap

    Define two report parameters (one start time and one end time), and set the filter criteria to the date column is greater than or equal to the start time and the date column is less than or equal to the end time.

    II. Example 1: Column filtering

    1. Preparing a template

    1) Create a general report, create a template dataset ds1, and the SQL statement is: SELECT * FROM ORDERS

    2) The form design is as follows:

    1.jpg

    3) Click Template > Template Parameters and add two report parameters, starttime and endtime. As shown below:

    2.jpg


    2. Adding widgets

    Enter the parameters panel and click the "Add All" button in the upper right corner to add two date widgets, as shown below:

    3.jpg


    3. Setting filter criteria

    Double-click on the A2 cell and select Filter to add the filter conditions shown below to the A2 cell. Filter conditions mean that the order date is greater than or equal to the start date and less than the end date.

    Note: If the database date or time is text type, it is recommended that users convert it to date or time type, because the principle of text size comparison does not comply with the date comparison situation.

    4.jpg


    4. Effect preview

    1) PC

    Save the template, click "Pagination Preview", select the start time and end time, click the query button, the effect is as shown below:

    5.jpg

    2) Mobile

    The end effect of App and HTML5 is as follows:

    gif.gif


    5. Completed template

    For the completed template, see: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\Parameter\TimeScale\Query_data_based_on_start_time_and_end_time.cpt

    Click to download the template: 

    Query_data_based_on_start_time_and_end_time.cpt

    III. Example 2: SQL filtering of the dataset

    1.Preparing templates

    1) Create a general report, create a template dataset ds1, and the SQL statement is:

    SELECT * FROM ORDERS where 1=1 ${if(len(starttime)=0,""," and SIGNDATE>='"+starttime+"'")}${if(len(endtime)

    =0,""," and SIGNDATE<'"+endtime+"'")} 

    2) The form design is as follows:

    1.jpg


    2. Adding widgets

    Enter the parameters panel and click the "Add All" button in the upper right corner to add two date widgets, as shown below:

    3.jpg


    3. Effect preview

    The effect is the same as in Section II of this article.


    4. Completed template

    For the completed template, see: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\Parameter\TimeScale\Query_data_based_on_start_time_and_end_time2.cpt

    Click to download the template: 

    Query_data_based_on_start_time_and_end_time2.cpt

    IV. Extension

    1. Usually, we need to verify: the start date and end date cannot be empty, the end date must be after the start date, and the end date must be within a certain period after the start date. Otherwise, relevant information will be found in JS Validate the Values of Date Widgets

    2. If you want to query data by year, month, and day in the same report, see Dynamic display parameter widget.

    Attachment List


    Theme: Parameter
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy