mercredi 21 mai 2014

c# - convertir des secondes en minutes au sein d'une requête - Stack Overflow


I have a data grid on my form that is populated using the following:


SELECT [Activity_Date], [Activity_duration_seconds] * FROM tblActivity

Is there any way that I can add an extra field onto this query that returns minutes?


Thank you.




You can compute whatever you want:


SELECT Column1, 
Activity_duration_seconds,
Activity_duration_seconds / 60 AS Activity_duration_minutes
FROM tblActivity



Just divide by 60 to get minutes:


select Activity_duration_seconds / 60 as activity_duration_minutes 
from tblActivity

(Assuming activity_duration_seconds is an integer column, 60 is also an integer, so you'll get it rounded down to whole minutes).


Or if you want minutes including the fractional part, then 60.0 will tell the db to treat it as a decimal:


select Activity_duration_seconds / 60.0 as activity_duration_minutes 
from tblActivity

And you'd get 2.05 or something like that, so part minutes too.



I have a data grid on my form that is populated using the following:


SELECT [Activity_Date], [Activity_duration_seconds] * FROM tblActivity

Is there any way that I can add an extra field onto this query that returns minutes?


Thank you.



You can compute whatever you want:


SELECT Column1, 
Activity_duration_seconds,
Activity_duration_seconds / 60 AS Activity_duration_minutes
FROM tblActivity


Just divide by 60 to get minutes:


select Activity_duration_seconds / 60 as activity_duration_minutes 
from tblActivity

(Assuming activity_duration_seconds is an integer column, 60 is also an integer, so you'll get it rounded down to whole minutes).


Or if you want minutes including the fractional part, then 60.0 will tell the db to treat it as a decimal:


select Activity_duration_seconds / 60.0 as activity_duration_minutes 
from tblActivity

And you'd get 2.05 or something like that, so part minutes too.


0 commentaires:

Enregistrer un commentaire