Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Anybody have a datediff class for foxpro
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00694033
Message ID:
00694196
Vues:
14
>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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform