# CF Calc Date Help

Question asked by ChristofferRexen_1 on Jan 31, 2017
Latest reply on Feb 2, 2017 by ChristofferRexen_1

Got this Custom Function, which I don't quite understand why is miscalculating.

// CF Name = DV_DateRange365Days

Let(

[

availableDates = Case (

not IsEmpty(startDate) and IsValid(startDate) and not IsEmpty (finishDate) and IsValid(finishDate) ; "both" ;

not IsEmpty(startDate) and IsValid(startDate) and IsEmpty (finishDate) ; "start" ; "none" ) ;

days = Case (

availableDates = "both" ; finishDate - startDate ;

availableDates = "start" ; Get(CurrentDate) - startDate ) ;

months = Round ( days/30 ; 0 ) ;

years = Round ( days/364,25 ; 0 )

];

Case

(

returnType = "d" ; days ;

returnType = "m" ; months ;

returnType = "y" ; years

)

)

Furthermore I got this CF.

// CF Name = DV_UdregnPeriodiskPræmieDays365

// Calculates the periodic premium, based on the number of days the insurance is designed for

// In:
// Insurance premium, Days the insurance is signed for
// OUT:
// 1st prize, measured in danish kroner distributed
in A whole year

// Constants in FEATURE: 365 (days)

//////////

Let (

// vars

[

days = 365 ;

result = ( premium / days ) * period

] ;

// calc

Round ( result ; 2 )

)

Now, when trying to use the two CFs'

KUN_Kunde_Police_Policetype::__kp_PolicetypeID = 80121 ; DV_UdregnPeriodiskPræmieDays365 ( ( Premium * KUN_Kunde_Police::Vandmængde ) ; DV_DateRange365Days ( DateStart ; DateEnd ; "d" ) )

DateStart = 01.01.2017

DateEnd = 31.12.2017

Although when trying this, the DV_DateRange365Days only calculates 364 days, despite the fact there is 365.

Could anyone lead me in the right direction?

Regards

CR