I'm in doubt on what kind I should use to work with hours on my system. Should I use DateTime
, Time
or TimeStamp
. I wish the times were saved in this format:
HH:MM
I'm in doubt on what kind I should use to work with hours on my system. Should I use DateTime
, Time
or TimeStamp
. I wish the times were saved in this format:
HH:MM
There is a specific type for this which is TIME
. This type has the seconds and fraction of them too (keep them zero if you do not need them), but usually it will not be a problem.
But it is not always necessary to use it. There are some situations with a type VARCHAR
may be sufficient. Of course it is more limited, it does not have the best semantics, but it depends on the use. But if you really want to avoid the seconds, it would be this way. You will have to handle the data manually.
On the other hand it is possible that this type is not enough for what you want and need to use another type where you have more control, even at the cost of less facilities. In some cases it may be VARCHAR
itself. In others it may be interesting to use DATETIME
or TIMESTAMP
, even if they have irrelevant information.
Just look at the exact situation to decide which is the best. But I will go in the native types first. If it is the case to sin for the excess would be more advantageous in most cases.