General information
Category:
Coding, syntax & commands
Erik,
Days360 uses two methods: US(default) and Europeun. I would slightly modify your function to accomadate it:
...
LPARA ldStart, ldEnd, llMethod
......
if llMethod &&European method
lnEndDay = IIF(lnEndDay = 31, 30, lnEndDay)
else &&Default
lnEndDay = IIF(lnEndDay<31,lnEndDay,;
iif(lnEndDay = 31 and lnStartDay<30, 31, 30))
endif
...
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>I am working on replacing an Excel spreadsheet to VFP in order to use the data for multiple reporting options. The data needs to be in a dbf format. Currently one of the calculations in the Excel spreadsheet uses the Excel function DAYS360. This returns the number of days between two dates based on a 360 day year (not 365 or 366 in leap years). I have been told this is a common accounting method. I have not found an equivalent VFP function to do this.
>
>Has anyone else seen this, is there a function in VFP that would return the same result, or has anyone else written a function to match this?
>
I believe the time calculation you want is called 30/360. I have a function that returns the number of years between two dates using this method, you can easily modify it to return days instead:
FUNCTION Years
LPARA ldStart, ldEnd
IF TYPE('ldStart') <> "D" OR TYPE('ldEnd') <> "D"
RETURN 0
ENDIF
LOCAL lnStartDay, lnEndDay, lnStartMonth, lnEndMonth, lnStartYear, lnEndYear, lnDays, lnYears
lnStartDay = DAY(ldStart)
lnEndDay = DAY(ldEnd)
lnStartMonth = MONTH(ldStart)
lnEndMonth = MONTH(ldEnd)
lnStartYear = YEAR(ldStart)
lnEndYear = YEAR(ldEnd)
lnStartDay = IIF(lnStartDay = 31, 30, lnStartDay)
lnEndDay = IIF(lnEndDay = 31, 30, lnEndDay)
lnDays = (lnEndDay - lnStartDay) + (30 * (lnEndMonth - lnStartMonth)) + (360 * (lnEndYear - lnStartYear))
lnYears = lnDays / 360
RETURN lnYears
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only