You must Sign In to post a response.
  • Category: SQL Server

    How to calculate Minitus

    how to calculate mintues in sql server.am using SP..and View ....
  • #750131
    Your question is not clear.
    from where you have to get difference in minute?
    Is it from two column ,table or from one column and current time?
    Any way you can get difference between two time or two dates by using datediff(MINUTE,'start time','end time')
    E.G.
    select datediff(MINUTE,'04:30','06:30')as [minutes]

    OUTPUT

    120 MIN.

    Regards,
    Nirav Prabtani (Senior Web Developer)
    Email : niravjprabtani@gmail.com
    blog : niravprabtani.blogspot.in

  • #750197
    Hi kirubaharan,

    I think your looking for difference between 2 dates in minutes format right.?

    If you are looking for the same then use below sample query


    select datediff(m,@in_time,@out_time);


    Try something like above to achieve your goal..

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #750209
    Hi,

    To find the time difference in minutes, you can use datediff function of sql as below-

    select datediff(MINUTE,'time1','time2')as [minutes]

    Thanks,
    Ashutosh Jha
    http://tricksroad.com

  • #750763
    Hi,

    Use the below sql script

    DECLARE @FromDate DATETIME,
    @ToDate DATETIME

    SELECT @FromDate = '2014-09-02 10:00:00',
    @ToDate = '2014-09-02 12:30:00'

    SELECT CONVERT(VARCHAR(12), DATEADD(minute, DATEDIFF(minute, @FromDate, @ToDate), 0),114)

    SELECT CONVERT(VARCHAR(5), DATEADD(minute, DATEDIFF(minute, @FromDate, @ToDate),0),114)


  • Sign In to post your comments