Date calculation

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
Moh Youba
Veteran Member
Posts: 40
Joined: 2017-03-12 09:31

Date calculation

Post by Moh Youba » 2019-07-28 06:36

Hello

Please I need help with date calculation. I want to calculate date from duration.

Date of start : 1/1/2000
Duration : 2 (from field)
End of training = date of start + duration (1/1/2002)

Thank you

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 525
Joined: 2018-04-01 10:12

Re: Date calculation

Post by pböttcher » 2019-07-28 07:57

Hi,
is your question to increase the year count by the duration?
And where do you want to do the calculation, in the front-end (via JS), on the server side (via PHP) or on the DB side (via SQL)?

Moh Youba
Veteran Member
Posts: 40
Joined: 2017-03-12 09:31

Re: Date calculation

Post by Moh Youba » 2019-07-28 08:09

Hello
I want to display via JS in the front-end, in the table view
Thank you

Moh Youba
Veteran Member
Posts: 40
Joined: 2017-03-12 09:31

Re: Date calculation

Post by Moh Youba » 2019-07-28 08:13

I try with something like this but do not work !!!

$j(function(){
$j('#dateOfStart').prop('readonly' , true);

$j('#dateOfStar-dd, #dateOfStar-mm, #dateOfStar').change(function(){
var dos = get_date('dateOfStare');
var today = new Date();
var duration= Math.abs(age_dt.getUTCFullYear() + today);

$j('#dateOfStar').val(age);
});

$j('#end_of_training').change();

});

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 525
Joined: 2018-04-01 10:12

Re: Date calculation

Post by pböttcher » 2019-07-28 15:58

Hi,

sorry I still do not get what you try to do.
What is age, age_dt, dateOfStart? dateOfStar is a selectable date in your app?

Maybe you can explain more in detail what you try and also post a screenshot.

Moh Youba
Veteran Member
Posts: 40
Joined: 2017-03-12 09:31

Re: Date calculation

Post by Moh Youba » 2019-07-28 16:33

ok sorry for my bad English, I will try to explain

Table name : training
3 fields (start_date - end_date - duration)
start_date (date type)
end_date (date type)
duration (integer type)

I want to display date base on this calculation
start_date + duration = end_date

for exemple
start_date : 1/1/2019
duration : 5 days
end_date will display : 6/1/2019

I hope this is more clear

Thank you

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 525
Joined: 2018-04-01 10:12

Re: Date calculation

Post by pböttcher » 2019-07-28 21:01

Hi, assuming that duration as integer means days you want to add you could try

$j(function(){
$j('#start_date-dd, #start_date-mm, #start_date').change(function(){
var start_date = $j('#start_date-mm').val()+"."+$j('#start_date-dd').val()+"."+$j('#start_date').val();
var duration = $j('#duration').val();
var dt = new Date(start_date);
var end_date= new Date(dt.getTime() +(duration *86400000));
$j('#end_date-mm').val((new Date(end_date)).getMonth()+1);
$j('#end_date-dd').val((new Date(end_date)).getDate());
$j('#end_date').val((new Date(end_date)).getFullYear())
});
})

Assuming that start_date and end_date are datepicker fields.

Moh Youba
Veteran Member
Posts: 40
Joined: 2017-03-12 09:31

Re: Date calculation

Post by Moh Youba » 2019-07-28 21:51

Hi
Thank you for your support, yes that start_date and end_date are datepicker fields.
I am going to try and back to you
Regards,

Post Reply