Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Datetime() operations
Message
From
13/07/2009 12:23:56
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01411971
Message ID:
01411972
Views:
47
>Can I operate directly to a datetime() with using numeric to characters transformations ?
>
>For example:
>
>store datetime() to my datime
>
>Sum 40 mintures to myDatetime
>
>Sum 2 hours to myDatetime
>
>Moises

Yes. Just remember that you are adding seconds, not days as with date values.

To add 40 minutes, add 40 * 60.

To add 2 hours, add 2 * 60 * 60.

I suggest you use descriptive constants, like this:
#DEFINE SECONDS_PER_MINUTE 60
#DEFINE SECONDS_PER_HOUR 3600
#DEFINE SECONDS_PER_DAY 86400

? datetime() + 40 * SECONDS_PER_MINUTE

? datetime() + 2 * SECONDS_PER_HOUR
Of course, the value of the constant won't change in the foreseeable future, but that way, you can search for this specific usage of "60" in your code.

The constants would be included in some global header file.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform