>I looking for a function that I could call like the datediff in SQLserver
>
>lnResults=datediff(mi,datetime1,datetime2) -- Return Minutes
>lnResults=datediff(yy,datetime1,datetime2) -- Years
>lnResults=datediff(hh,datetime1,datetime2) -- Hours
>lnResults=datediff(mm,datetime1,datetime2) -- Months
>
>etc..
Something like this:
Function iDateDiff
lParameter pcType, ptStart, ptEnd
do case
case pcType="mi"
return (ptEnd- ptStart)/60
case pcType="hh"
return (ptEnd- ptStart)/3600
case pcType="mm"
local ldEnd, ldStart
ldEnd=ttod(ptEnd)
ldStart=ttod(ptStart)
return (year(ldEnd)+month(ldEnd)/12-year(ldStart)-month(ldStart)/12)*12
case pcType="yy"
return year(ttod(ptEnd))-year(ttod(ptStart))
otherwise
return 0 && or what needed to initiate the error
endcase
*Depending on what 'difference' you actually need, you may also use *year/month/day... fractions to get more correct result.
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