Re: [HS] MySQL : manipulation arithmétique su r des "time"

Pàgina inicial

Reply to this message
Autor: Olivier Guerrier
Data:  
A: ML Guilde
Assumptes vells: [HS] MySQL : manipulation arithmétique sur des "time"
Assumpte: Re: [HS] MySQL : manipulation arithmétique su r des "time"
Je reposte sur [guilde] et j'en profite pour rajouter un détails à la fin.

Patrice Karatchentzeff wrote:
| Salut,


Bonjour,
je précise que je ne suis pas spécialiste MySQL, juste utilisateur ...

| J'ai une question à deux balles : j'avais cru comprendre que l'on
| pouvait _manipuler_ des heures (format hh:mm:ss) facilement sous MySQL


Je crois que c'est surtout les dates aaaa-mm-jj hh:nn:ss je ne sais pas
comment il réagit sur des soustractions d'heures.


| mysql> select vehicules2.nom, (vehicules2.heure_fin -

vehicules2.heure_debut) from vehicules2 where vehicules2.nom = "VSAB"
group by vehicules2.nom;
| +------+-------------------------------------------------+
| | nom  | (vehicules2.heure_fin - vehicules2.heure_debut) |
| +------+-------------------------------------------------+
| | VSAB |                                           26600 |
| +------+-------------------------------------------------+

...
| Une idée ?

|

essaye select vehicules2.nom, SEC_TO_TIME(TIME_TO_SEC(vehicules2.heure_fin)-
TIME_TO_SEC(vehicules2.heure_debut)) from vehicules2 where ...

ici ça donne ça:
mysql> select SEC_TO_TIME(TIME_TO_SEC("19:00:00")-TIME_TO_SEC("16:34:00"));
+--------------------------------------------------------------+
| SEC_TO_TIME(TIME_TO_SEC("19:00:00")-TIME_TO_SEC("16:34:00")) |

+--------------------------------------------------------------+
| 02:26:00                                                     |

+--------------------------------------------------------------+

Olivier