Hackers Guide to Visual FoxPro 7.0

Hour(), Minute(), Sec()

These functions extract the hour, minute and second portions of a datetime value. Backward compatibility with previously existing functions makes for some funny, non-intuitive abbreviation rules.

Usage

nHours = HOUR( tDateTime ) nMinute = MINUTE( tDateTime ) nSeconds = SEC( tDateTime )

Hour() always returns the number of hours since midnight, regardless of the setting of SET HOUR. Minute() returns a numeric value from 0 to 59. No surprises here. Minute() may be abbreviated as short as Minu(), but realize that MIN() is the Minimum function, something completely different. Though confusing, it fits the general rule that you can abbreviate commands and functions to four characters or more. Sec() returns a numeric value from 0 to 59. In the opposite logic to Minute(), Sec() must be just the three characters—anything from Seco() up to Seconds() causes Visual FoxPro to return the number of seconds since midnight, or squawk if a parameter is passed.

Example

? "The time is now " + LTRIM(STR(HOUR(DATETIME()))) + ; " hours, " + LTRIM(STR(MINUTE(DATETIME()))) + ; " minutes and " + LTRIM(STR(MINUTE(DATETIME()))) + ; " seconds past midnight"

See Also

Date(), DateTime(), Min(), Seconds(), Set Hour

View Updates

Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.

Категории