Seek help!! SQL dynamically finds the time difference

Updated on society 2024-05-07
12 answers
  1. Anonymous users2024-02-09

    Be clear. I've done this question before.

  2. Anonymous users2024-02-08

    select temp.*

    datediff(mi, as datetime), as datetime)) Time difference (minutes).'

    from temp,(select * from temp) awhere

    andand 'b'

    and 'r'

    Below is a screenshot.

  3. Anonymous users2024-02-07

    What kind of database?

    sqlserver

    select cast(floor(datediff(minute, time 1, time 2) 1440) as varchar)+'days'+

    cast(floor((datediff(minute,time 1,time 2) %1440) 60) as varchar)+'hours'+

    cast(((datediff(minute, time 1, time 2))-

    floor(datediff(minute, time 1, time 2) 1440) *1440)-

    floor((datediff(minute,time1,time2)%1440)60)*60)) as varchar)+'points'

    from the table name.

    I tested it just now: the results are as follows.

    If you have any questions, please feel free to ask.

  4. Anonymous users2024-02-06

    select datediff(day,getdate(),getdate()) number of days difference.

    select datediff (hour,getdate()-2,getdate())) hour difference value 24, which is the day.

    select datediff (minute,getdate()-2,getdate()) is the minute difference between two dates, the value is 24, the number of days is the difference, the residual value is 60, the hour difference, and the remainder is minutes.

  5. Anonymous users2024-02-05

    selec tdatediff( second, '2009-8-25 12:15:12', '2009-9-1 7:18:20') - Returns the number of seconds of phase difference.

    selec tdatediff( minute, '2009-9-1 6:15:12', '2009-9-1 7:18:20') - Returns the number of minutes of phase difference.

    selec tdatediff( day, '2009-8-25 12:15:12','2009-9-1 7:18:20') -- Returns the number of days in which the difference is returned.

    selec tdatediff( hour, '2009-8-25 12:15:12', '2009-9-1 7:18:20') -- returns the hour of the difference.

  6. Anonymous users2024-02-04

    select sum(datediff(millisecond,createtime, closetime))as total number of high seconds from table name where msisdn=138

    select sum(datediff(minute,createtime, closetime))as total number of seconds from table name where msisdn=138

    select sum(datediff(minute,createtime, closetime))as total minutes from table name where msisdn=138

    select sum(datediff(hour,createtime, closetime))as total hours from table name where msisdn=138

    select sum(datediff(day,createtime, closetime))as total number of days from table name where msisdn=138

    select sum(datediff(week,createtime, closetime))as total number of days from table name where msisdn=138

    select sum(datediff(month,createtime, closetime))as total number of days from table name where msisdn=138

    select sum(datediff(quarter,createtime, closetime))as total number of quarters from table name where msisdn=138

    select sum(datediff(year,createtime, closetime))as total number of years from table name where msisdn=138

    The landlord didn't say the unit of time, I listed them all, you choose.

  7. Anonymous users2024-02-03

    What kind of database? Here's a generic one for you.

    select time 1, time 2, field 3 from the table name union all

    select '','', sum(field 3) from the table name is the last and previous row to summarize the value.

  8. Anonymous users2024-02-02

    declare @starttime as datetime

    declare @endtime as datetime

    set @starttime = '2009-11-21 00:00:00'

    set @endtime = '2009-11-24 15:12:24'select right('00'+ cast(cast(datediff(ss ,@starttime,@endtime) / 3600 as int) as varchar),2) +':

    right('00'+ cast(cast(datediff(ss ,@starttime,@endtime) %3600 / 60 as int) as varchar),2) +':' +

    right('00'+ cast(cast(datediff(ss,@starttime,@endtime) %60 as int) as varchar),2) as time difference.

    The time difference is ---

    87:12:24 (1 line affected).

  9. Anonymous users2024-02-01

    Is oracle sql2000?

    Give an example of an oracle:

    select floor(to_number(to_date(20110621100000,'yyyymmdd hh24:mi:ss')-to_date(20110621095505,'yyyymmdd hh24:

    mi:ss'))*24*60) from dual;

  10. Anonymous users2024-01-31

    The usage of SQL is as follows.

    datediff(minute,createdtime,updatedtime)

    Please refer to it.

  11. Anonymous users2024-01-30

    The two times can be subtracted, and the result can be obtained by the landlord by himself using the conversion relationship of days-hours-minutes.

  12. Anonymous users2024-01-29

    Normally, the number of seconds of time difference is calculated using a datediff function such as select datediff(s,).'2013-01-07','2013-04-01')

    This is the number of seconds between April 1, 2013 and January 7, 2013, but what do you mean by the time difference between the times?

    Is the back line minus the front line?

    Also Which version of mssql are you?

Related questions
8 answers2024-05-07

The full update to this order of magnitude will certainly be slow. >>>More

5 answers2024-05-07

Of course; Just use the row to the column.

Static writing. select unit,sum(case when year(time)=2005 and datepart(q,time)=1 then value else 0 end) as 2005 a quarter,sum(case when year(time)=2005 and datepart(q,time)=2 then value else 0 end) as 2005 a quarter ,.. >>>More

4 answers2024-05-07

select * from log a,(select ,max(date) from logwhere id='10000' >>>More

8 answers2024-05-07

select datediff(day, (select from table where id=1 )

getdate()) >>>More

18 answers2024-05-07

Enterprise Manager directly with SQL has this feature.