Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Datetime-local - filter Topic is solved

Questions related to using nuBuilder Forte.
Post Reply
yvesf
Posts: 315
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 87 times
Been thanked: 11 times

Datetime-local - filter

Unread post 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 ?
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Datetime-local - filter

Unread post by kev1n »

How is the table filtered?
yvesf
Posts: 315
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 87 times
Been thanked: 11 times

Re: Datetime-local - filter

Unread post by yvesf »

Capture.PNG
It's filter by acc_date which is a date and not a datetime
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Datetime-local - filter

Unread post 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()
yvesf
Posts: 315
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 87 times
Been thanked: 11 times

Re: Datetime-local - filter

Unread post 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
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Datetime-local - filter

Unread post 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.
yvesf
Posts: 315
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 87 times
Been thanked: 11 times

Re: Datetime-local - filter

Unread post 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 ?
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Datetime-local - filter

Unread post 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
You do not have the required permissions to view the files attached to this post.
yvesf
Posts: 315
Joined: Sun Mar 14, 2021 8:48 am
Location: Geneva
Has thanked: 87 times
Been thanked: 11 times

Re: Datetime-local - filter

Unread post by yvesf »

Thx Kev1n, it works with your proposal.
Post Reply