Page 1 of 1

Datetime-local - filter

Posted: Wed Apr 13, 2022 6:39 pm
by yvesf
I have a launch form that filters a table below with the date which is a date field. The table below contains a datetime-local because I need the time. When I filter with the current date the liste below is empty : I have to create a second field containing the date only. Is there another way to perform this operation ?

Re: Datetime-local - filter

Posted: Thu Apr 14, 2022 7:13 am
by kev1n
How is the table filtered?

Re: Datetime-local - filter

Posted: Thu Apr 14, 2022 6:42 pm
by yvesf
Capture.PNG
It's filter by acc_date which is a date and not a datetime

Re: Datetime-local - filter

Posted: Fri Apr 15, 2022 7:29 am
by kev1n
What date format has acc_date? You might have to convert it to the format yyyy-mm-dd when passing it in nuFilterRun()

Re: Datetime-local - filter

Posted: Fri Apr 15, 2022 9:42 am
by yvesf
acc_date is in 'dd/mm/yyyy format'. I will try by changing the format.Format of the DateTime in tache_iframe is 'dd/mm/yyyy hh:nn' with is the same as acc_date. Do you think that the system doesn't take those formats into account but works with the default format for the search ? I will try. Thx

Re: Datetime-local - filter

Posted: Fri Apr 15, 2022 10:55 am
by kev1n
Try with a static date value like nuFilterRun('tache_iframe','2022-04-03') to see if the iFrame is refreshed. Then you know if the date needs to be in that format.

Re: Datetime-local - filter

Posted: Fri Apr 15, 2022 2:08 pm
by yvesf
If I change nuFilterRun('tache_iframe', '#acc_date#') by nuFilterRun('tache_iframe','2022-04-13') in order to filter on the 13th of april, it doesn't work. Could you please explain how the filterRun works on dates ?

Re: Datetime-local - filter

Posted: Fri Apr 15, 2022 7:01 pm
by kev1n
nuFilterRun() adds a WHERE clause in your SQL. When you inspect the generated SQL (Option Menu, Form Info) you will see an sql like

Code: Select all

SELECT your_table_id, your_date_column FROM your_table WHERE 1 AND CONVERT(your_date_column USING utf8) LIKE "%2022-04-16%") )
If you convert your date format from dd/mm/yyyy to yyyy-mm-dd, the filter should just work fine.

Code: Select all

let arr = this.value.split('/');
nuFilterRun('tache_iframe',arr[2] + '-' + arr[1] + '-' + arr[0]);
filter.png

Re: Datetime-local - filter

Posted: Sat Apr 16, 2022 12:12 am
by yvesf
Thx Kev1n, it works with your proposal.