We will show you how to filter a query by date range, using the current date and time. We'd like to setup a query which returns only the records which dates are in the period from today to a month back. This is very useful for creating sales or delivery reports. As usual, first let's create our server action file (1). And add a name for it (2). Then, right click steps. And add a database connection (3).
Select your database connection from the or create a new one, if you haven't done this yet.
then, right click the database connection step (1). And add a database query (2).
Open the query options (1). and add your database table to the query (2). Then add the columns you need, to the selected columns list (3). Open the filters tab (5).
And select the column, containing the dates (1). Add it to the filters list (2). Open the operator dropdown (3). And select - between. Click the dynamic value button in order to setup the first date for the period (4).
Under globals, select now in order to use the current date and time (1). And then click the format value button (2).
Right click the now value (1). And open the date and time filters. Select date add (2).
Click interval in order to select the date interval (1). Open the dropdown. We select months (2). Then click number. Here we enter the interval length (3). We'd like to display only the dates, from the past month, so we enter minus 1. Click select (4).
and click select in order to apply the filter. then, let's setup the second date, of the interval. Click the dynamic data button. and under globals select now(1). Click the select button (2).
Then select the type. Our database field type, is Date, so we select Date. If your database field is date time select date and time (1). Click OK (2).
And save your action file. And you are done. Now your database query returns only the records in the selected interval. That's how easy it is to filter a query by date range, using the current date and time.