views:

16

answers:

2

Does MySql has the Interval datatype as PostgreSQL (or like TimeSpan in .net) does?

A: 

No. There are interval functions, but not datatypes.

If the intervals you're concerned with are less than 838 hours, you might be able to use the TIME type to get the behavior you want.

From the manual:

MySQL interprets TIME values as elapsed time rather than as time of day.
kijin
A: 

Nope, there is no time interval data type in MySQL. There is a feature request for one though, but apparently it hasn't gotten much attention.

The time type can be used for such a purpose though, as suggested by the documentation

MySQL retrieves and displays TIME values in 'HH:MM:SS' format (or 'HHH:MM:SS' format for large hours values). TIME values may range from '-838:59:59' to '838:59:59'. The hours part may be so large because the TIME type can be used not only to represent a time of day (which must be less than 24 hours), but also elapsed time or a time interval between two events (which may be much greater than 24 hours, or even negative).

Eric Petroelje