Paradox Community
Search:

 Welcome |  What is Paradox |  Paradox Folk |  Paradox Solutions |
 Interactive Paradox |  Paradox Programming |  Internet/Intranet Development |
 Support Options |  Classified Ads |  Wish List |  Submissions 


Paradox Programming Articles  |  Beyond Help Articles  |  Tips & Tricks Articles  


Paradox® Date, Time, and DateTime Data Types
Introduction and Internal Formats
© 2001 Rick Kelly
www.crooit.com

Download the library containing the routines used in this series.

Preface

Time is represented in Paradox as:
  1. Date - A specific day
  2. Time - Time of day
  3. DateTime - A specific day and time
ObjectPAL® (OPAL) has many methods available for the manipulation of these values, including arithmetical operations. The basis for many OPAL methods revolves around the internal representation of each type. We will take a look at each type and its internal storage format and how this information can be used as the foundation for extending the capability of OPAL calculations and derivations in ways that are not dependent on environmental settings such as those found in the BDE and Windows.

The following definitions will form the basis of the presented OPAL methods in later sections.


Date

In OPAL, you can externally represent Date values in either month/day/year, day-month-year, or day.month.year format as determined by the formatSetDateDefault method (System type), or by custom OPAL formatting statements for other external representations.

Internally, Date values are stored as long integers representing the number of days since January 1 of year 1 which is day 1. The span of dates supported is an incredible May 4, -30799 (-2,147,483,648) to July 11, 18629 (2,147,483,647). Later, we will see how dates prior to January 1, 0001 need to be adjusted for accurate calculations.

For example:

June 21, 2001 is stored as 730,657
December 25, 1950 is stored as 712,216

This internal Date type format will be defined for future reference as:

Definition: liFixedDate = Internal long integer Date type
Calculation: longInt(daAny) where daAny is an OPAL Date type


Time

OPAL Time variables store times in hour-minute-second-millisecond format.

Internally, Time values are stored as long integers representing the number of milliseconds since midnight which is 0. Range of possible values is 0 - 86,359,999 for a total of 86,400,000 milliseconds in each day.

For example:

12:00:00 PM (Noon) is stored as 43,200,000
06:00:00 AM is stored as 2,160,000

This internal Time type format will be defined for future reference as:

Definition: liFixedTime = Internal long integer Time type
Calculation: longInt(tiAny) where tiAny is an OPAL Time type


DateTime

OPAL DateTime variables store data in the form hour-minute-second-millisecond year-month-day format.

Internally, DateTime values are stored as a floating point number representing the number of milliseconds from midnight January 1, 0001.

For example:

June 1, 2001 at 12:00:00 PM (Noon) = 63,127,080,000,000

This internal DateTime type format will be defined for future reference as:

Definition: nuFixedDateTime = Internal Number DateTime type
Calculation: number(dtAny) where dtAny is an OPAL DateTime type


Next: Adjustments to Dates prior to January 1, 0001

References
Common / Shared ObjectPALŽ Routines


Discussion of this article


 Feedback |  Paradox Day |  Who Uses Paradox |  I Use Paradox |  Downloads 


 The information provided on this Web site is not in any way sponsored or endorsed by Corel Corporation.
 Paradox is a registered trademark of Corel Corporation.


 Modified: 15 May 2003
 Terms of Use / Legal Disclaimer


 Copyright © 2001- 2003 Paradox Community. All rights reserved. 
 Company and product names are trademarks or registered trademarks of their respective companies. 
 Authors hold the copyrights to their own works. Please contact the author of any article for details.