Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Rounding DateTime
Message
De
11/12/2000 17:57:20
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00451939
Message ID:
00451944
Vues:
25
>I know I've seen an article or thread on rounding numbers, but I can't find them. What I'm looking to do is take a datetime field like 12/11/2000 16:33:00 and round it to the nearest 15 minute period so the result would be 12/11/2000 16:00:00
>
>If anyone can point me to a thread or article I would greatly appreciate it.
>
>Kirk
How about some code?
LParameters ttDatetime
Local lnDay, lnHour, lnMin, lnMonth, lnSec, lnYear 

lnYear = Year(ttDatetime)
lnMonth = Month(ttDatetime)
lnDay = Day(ttDatetime)
lnHour = Hour(ttDatetime)
lnMin = Minute(ttDatetime)
lnSec = 0

*--     get nearest 15 minutes
lnMin = Round(lnMin/15,0)*15

If lnMin = 60
     lnMin = 0
     lnHour = lnHour + 1
     If lnHour = 24
          lnHour = 0
          lnDay = lnDay + 1
     EndIf
EndIf

Return Datetime(lnYear, lnMonth, lnDay, lnHour, lnMin, lnSec)
Insanity: Doing the same thing over and over and expecting different results.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform