TIME - Firebird

In dialect 3, TIME stores the time of day, with no date portion: “time-only.” Storage is a 32-bit unsigned integer. Storable times range from 00:00 to 23:59:59.9999.

Dialect 1 has no equivalent to the dialect 3 TIME type. If time of day needs to be stored, extract the hours, minutes, and seconds elements from the DATE data and convert it to a string. A suggested technique follows later in this chapter—refer to the section “Combining EXTRACT( ) with Other Functions.”

Interval of Time (Time Elapsed)

It is a common mistake to assume that TIME can store an interval of time (time elapsed). It cannot . To calculate an interval of time, subtract the later of two date or time types from the earlier. The result will be a NUMERIC (18,9) number expressing the interval (time elapsed) in days. Because of precision loss, sub-seconds should be considered accurate to milliseconds, rather than ten-thousandths of seconds. Use regular arithmetic operations to convert days to hours, minutes, or seconds, as required.

Suppose, for example, that the columns STARTED and FINISHED are both TIME-STAMP (or DATE in dialect 1). To calculate and store the time elapsed in minutes into a DOUBLE PRECISION column TIME_ELAPSED, you would use the following:

UPDATE ATABLE SET TIME_ELAPSED = (FINISHED - STARTED) * 24 * 60 WHERE ((FINISHED IS NOT NULL) AND (STARTED IS NOT NULL));

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Firebird Topics