Hi,
I have made a form which my network accounts can insert the start holiday date and end holiday date.
I store this dates in my database, but before I want to make a difference between them,for only workly days.
I have wrote the following script, but it is wrong if I sign a date that do not get me one week holiday (because [days/7],start:18/01/2002 end:23/01/2002, it make a wrong calculation):
$dfromconvert = explode("-",$dfrom);
//esplode la data [Giorno-mese-anno]
$dtoconvert = explode("-",$dto);//esplode la data [Giorno-mese-anno]
$dfrommktime = mktime(0,0,0,$dfromconvert[1],$dfromconvert[0],$dfromconvert[2]);//riassembla la data esplosa!
$dtomktime = mktime(0,0,0,$dtoconvert[1],$dtoconvert[0],$dtoconvert[2]);//riassembla la data esplosa!
$days = (intval((($dtomktime-$dfrommktime)/86400)+1));
print $days;
$weekends = ((intval($days/7))2);
print $weekends;
$hours = (($days-$weekends)8);
print $hours;
$note=str_replace("'","\''",$note);
$db_act = "insert into request
values ($dip_id,sysdate,to_date('$dfrom','DD-MM-YYYY'),to_date('$dto','DD-MM-YYYY'),'$type',$cause,'$id_sessione','$note',NULL,NULL,'RICHIESTA','$hours')";
db_action ($db_act);
Can you help me to resolve this problem, maybe with a calendar function.
Thanks a lot.
Marco