Microsoft KB Archive/176043

= How To Add or Subtract Time with a DateTime Data Type =

Article ID: 176043

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Visual FoxPro 3.0b for Macintosh

-



This article was previously published under Q176043



SUMMARY
This article describes how to add or subtract time with a DateTime field. Time, in seconds, can be added or subtracted with a DateTime data type field. Time carries over from seconds to minutes to hours to days and to years. There are no adjustments in this sample for a leap year. This is an example and you may want to add additional functionality if time calculations are a large part of your application.



MORE INFORMATION
When you add or subtract time with a DateTime field, the value(s) to add or subtract will be calculated with seconds.

Example to add an hour: HourFromNow = Datetime + 3600 -or-

Example to subtract a week: WeekAgo = Datetime - (7*24*3600) (c) Microsoft Corporation, 1997, All Rights Reserved. Contributions by Mike Fernald, Microsoft Corporation

Additional query words: datetime day hour minute second hh:mm:ss

Keywords: kbhowto KB176043

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.