Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

How to subtract dates to calculate nights

Questions related to using nuBuilder Forte.
joecocs
Posts: 67
Joined: Wed Jul 04, 2018 4:11 pm
Location: France

Re: How to subtract dates to calculate nights

Unread post by joecocs »

after several hours of research with the console, I don't see a problem.

On the other hand by delving a little I found in the nudebug results errors every time I navigate in the forms and that this queries the database

In nudebug results i've this :
===USER==========

globeadmin

===PDO MESSAGE===

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE 1' at line 2

===SQL===========

SELECT
WHERE 1

===BACK TRACE====

/volume1/web/ISEA/nuform.php - line 350 (nuRunQuery)

/volume1/web/ISEA/nuform.php - line 331 (nuBrowseTotals)

/volume1/web/ISEA/nuapi.php - line 42 (nuGetFormObject)
Can it have a consequence?
kev1n
nuBuilder Team
Posts: 4581
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 536 times
Contact:

Re: How to subtract dates to calculate nights

Unread post by kev1n »

Did you translate the months names to French? Could use set the language to English for globeadmin, log in again and see if the onchange event is triggered?
joecocs
Posts: 67
Joined: Wed Jul 04, 2018 4:11 pm
Location: France

Re: How to subtract dates to calculate nights

Unread post by joecocs »

I'm sorry but nothing more, I still have the error of illegal caracters.

on the other hand after having browsed several forums,

you are sure on the syntax of the onchange code,

notably the quotes “ “ ?

Code: Select all

dureeprojets(“Date_Debut_Projets“,“Date_Fin_Projets“);
kev1n
nuBuilder Team
Posts: 4581
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 536 times
Contact:

Re: How to subtract dates to calculate nights

Unread post by kev1n »

Now I see the error. Replace your double quotes ( “ ) with ( " ) or with single quotes ( ' )

Code: Select all

dureeprojets("Date_Debut_Projets","Date_Fin_Projets");
joecocs
Posts: 67
Joined: Wed Jul 04, 2018 4:11 pm
Location: France

Re: How to subtract dates to calculate nights

Unread post by joecocs »

YESSSSSSSSSS !

Thank's

How do we make this symbol (")
joecocs
Posts: 67
Joined: Wed Jul 04, 2018 4:11 pm
Location: France

Re: How to subtract dates to calculate nights

Unread post by joecocs »

YESSSSSSSSSS !

Thank's

How do we make this symbol (")

on the other hand the result is not saved in the fields ??? :?:
kev1n
nuBuilder Team
Posts: 4581
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 536 times
Contact:

Re: How to subtract dates to calculate nights

Unread post by kev1n »

No idea, because I'm not using a frech keyboard. But you can use single quotes as well ( ' )

You need to add a .change();

Code: Select all

 $('#Duree_Projets').val(subtractDateFields(f1,f2)).change();
joecocs
Posts: 67
Joined: Wed Jul 04, 2018 4:11 pm
Location: France

Re: How to subtract dates to calculate nights

Unread post by joecocs »

for my understanding, what the element corresponds to: 2e3 in the code :

Code: Select all

return Math.round(timeDiff / (2e3 * 3600 * 365.25));
kev1n
nuBuilder Team
Posts: 4581
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 536 times
Contact:

Re: How to subtract dates to calculate nights

Unread post by kev1n »

It's called scientific notation. 2e3 is the same as 2 x 10^3, which is 2000
joecocs
Posts: 67
Joined: Wed Jul 04, 2018 4:11 pm
Location: France

Re: How to subtract dates to calculate nights

Unread post by joecocs »

Yes I know the notation

but it is to calculate what.

the calculation of 'diffTime is in milliseconds,
3600 for the hours and
365.25 for the year
but 2e3?
Post Reply