Custom Function to Calculate No. of Days between two Days


Posted by Shamsuddeen. P.K on December 09, 2001 9:10 AM

I have created the following function which calculates the number of days between two given dates:

Function TotDays(EndDate,StartDate)
TotDays = EndDate - StartDate
End Function

The above function is working fine but te problem is that every time I use the function, I have to give the EndDate and StartDate in either of the following formats:

=TotDays(DATE(2001,12,31), DATE(2001,6,15) or

=TotDays(DATEVALUE(12-31-2001"),DATEVALUE("6-15-2001"))

In the above function, I want to give the dates in a simplified way such as :

=TotDays(31-12-2001, 15-6-2001) and the function should convert the dates to the required format and calculate the number of days.

Any help !!!!

Regards,

Shamsuddeen. P.K



Posted by Balthasar on December 09, 2001 4:56 PM

This works for me (no UDF needed) :-

="31-12-2001"-"15-6-2001"