In SQL there are three field types for storing date and time values :
- DATE: Stores date values.
- TIME: Stores time values.
- TIMESTAMP: Stores date and time values.
These types are supported in different databases, though each version
has its own implementation and storage method.
Some advantages of using date-time field types instead of
strings are:
-
Your databases will be standard in working with
date and date-time values.
-
It will be possible to use date functions, such as comparing to today, in
queries.
- These field types always will contain valid date/date-time values. Values will be general and not depended to any calendar.
- Date-Time fields have a lot of usages because they have date and time in one
existence while date-time arithmetic calculations are possible
on them.
- Calculations with date and date-time fields are simply possible but not with
string fields. For example difference between two date field values
can be found with “Field1-Field2” or it’s possible to add an
arbitrary count of days or amount of time to a date or date-time field’s value.
- This is the only solution when writing applications that work with both calendars.
You will not need conversion routines to have both Jalali and Gregorian representations.
- You can take advantages of
TShDateField and TShDateTimeField
classes in Delphi.
|