DMXzone Server Connect Support Product Page

Answered

filter records by date older than 1 month

10 May 2016 08:49:27 Herve de Brabandère 7ok sprl posted:
hello,
I want to have a list of records where date field is older than 1 month (or 31 days).
How can I do that using server connect ?
I tried to filter using now-31 without succes
Using Mysql i do it like this
SELECT *
FROM mesdates
WHERE mesdates.my_date <= DATE_SUB( NOW( ) , INTERVAL 1 MONTH )

Thanks

Replies

Replied 12 May 2016 08:33:19
12 May 2016 08:33:19 Herve de Brabandère 7ok sprl replied:
any idea ?
Replied 12 May 2016 12:40:10
12 May 2016 12:40:10 Teodor Kuduschiev replied:
Hello, unfortunately this is not yet possible.
It will be possible with the release of dmxzone server formatter.
Replied 20 May 2016 18:43:18
20 May 2016 18:43:18 Dave Smith replied:
You could add a date range filter to the results and filter by date => DATEINPUTNAME

Would allow the user to go back 31 days or any amount of days for that matter. Partner with Filter as you Type and you would have instant results.

www.dmxzone.com/go/22476/filter-as-you-type-with-html5-data-bindings

Just an idea/workaround..
Replied 21 May 2016 07:15:16
21 May 2016 07:15:16 Herve de Brabandère 7ok sprl replied:
Tank you Dave,
To cope with this need i use session variable
<?php
if (!session_id()) session_start();
$_SESSION['ma_date']=date('Y-m-d', strtotime('-31 days'));
?>
Then i define this session variable within server connect and use it in the filter
Just to know how do you add a date range filter to the results ?
Regards
Replied 21 May 2016 10:11:01
21 May 2016 10:11:01 Dave Smith replied:
Hi Herve,
You have a couple of options. This is a nice solution (using java):

www.daterangepicker.com/#ex4

Or as I mentioned above. You would create your query in Server Connect to Filter by a selected date via a form input, and store these input values in a Cookie (DMX State Management is an excellent tool or you could write the code yourself), or Post in to a URL variable etc.



Like this:



I do this to allow users to Filter by a date range and store the start date and end date of the range in Cookies to power an accounting report. As I said the user would specify the date range themselves by selecting the start and end dates. Works for me and my client.

This is the result:



Hope that makes sense..

Reply to this topic