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
Date calculation
Re: Date calculation
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)?
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)?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Date calculation
Hello
I want to display via JS in the front-end, in the table view
Thank you
I want to display via JS in the front-end, in the table view
Thank you
Re: Date calculation
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();
});
$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();
});
Re: Date calculation
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.
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.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Date calculation
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
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
Re: Date calculation
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.
$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.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Date calculation
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,
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,