Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Round Time To Nearest 15 Minutes
Message
From
01/06/2016 06:26:41
 
 
To
01/06/2016 05:29:08
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows Server 2008 R2
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01636901
Message ID:
01636911
Views:
56
>>>I've been struggling with rounding time to the nearest 15. Any suggestions? I figured I need to convert the minutes to seconds first but can figure out the equation to round to the nearest 15 minutes.
>>>
>>>TIA
>>>Jeff
>>
>>
>>Here is another one, just for 15 min intervals:
>>
>>
>>
>>LPARAMETERS ttDateTime as Datetime
>>
>>LOCAL ltDateTime as Datetime, lnMinDT as Integer
>>lnMinDT		= MINUTE(ttDateTime)
>>lnMinDiff	= ICASE( BETWEEN(lnMinDT,0,14), 15-lnMinDT ;
>>	, BETWEEN(lnMinDT,15,29), 30-lnMinDT ;
>>	, BETWEEN(lnMinDT,30,44), 45-lnMinDT ;
>>	, 60-lnMinDT)
>>ltDateTime	= ttDateTime + lnMinDiff*60 - SEC(ttDateTime)
>>
>>RETURN ltDateTime
>>
>
>Fernando, your function is always pointing to the next interval, isn't it? For instance, {^2016-06-01 10:00:01} returns {^2016-06-01 10:15:00}, and {^2016-06-01 10:15:01} returns {^2016-06-01 10:30:00}.
>
>The way I understood Jeff's requirement, he is looking for the nearest 15-minute interval, so it should be {^2016-06-01 10:00:00} and {^2016-06-01 10:15:00}, instead.

Well, given this "short" spec and no examples, I think that we can't know for sure what behavior he wants :D

Yes, I've rounded to the next 15 mins, dividing an hour in 4 (15 mins) segments
Fernando D. Bozzo
Madrid / Spain
Previous
Reply
Map
View

Click here to load this message in the networking platform