Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Rounding DateTime
Message
From
11/12/2000 17:57:20
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00451939
Message ID:
00451944
Views:
24
>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.
Previous
Reply
Map
View

Click here to load this message in the networking platform