Domanda

I created a table with one attribute tt and inserted a value into it.

CREATE TABLE tt(tm TIME);
INSERT INTO tt VALUES(2342342);

On executing the select command the result shown is in the form :

234:23:42

What time does this signify ?

È stato utile?

Soluzione

MySQL retrieves and displays TIME values in HH:MM:SS format or HHH:MM:SS format for large hour values. The reason why it can have large values is because it can also represent an interval between two events (which may span over multiple days for example, or even be negative).

H stands for hour, M for minute, and S for second.

So, when you insert 2342342 it becomes 234:23:42 representing 234 hours, 23 minutes, and 42 seconds.

Reference

Altri suggerimenti

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).

http://dev.mysql.com/doc/refman/5.0/en/time.html

MySQL recognizes TIME values in these formats:

As a string in 'D HH:MM:SS' format. You can also use one of the following “relaxed” syntaxes: 'HH:MM:SS', 'HH:MM', 'D HH:MM', 'D HH', or 'SS'. Here D represents days and can have a value from 0 to 34.

As a string with no delimiters in 'HHMMSS' format, provided that it makes sense as a time. For example, '101112' is understood as '10:11:12', but '109712' is illegal (it has a nonsensical minute part) and becomes '00:00:00'.

As a number in HHMMSS format, provided that it makes sense as a time. For example, 101112 is understood as '10:11:12'. The following alternative formats are also understood: SS, MMSS, or HHMMSS.

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-literals.html

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top