Professional Web Applications Themes

calculate the time - Microsoft SQL / MS SQL Server

Personal, necessary to do a select that contains for NAME, if the name has more than a connection I want to catch the total time of those connections in the format hh:mm:ss, the format of the field is DATETIME and I have a field with the beginning and the end of the connection. I am getting to only calculate the time for each connection of the name but I am not getting to see the total time. Will it be that anybody could help?...

  1. #1

    Default calculate the time



    Personal, necessary to do a select that contains for NAME, if the name has
    more than a connection I want to catch the total time of those connections
    in the format hh:mm:ss, the format of the field is DATETIME and I have a
    field with the beginning and the end of the connection.
    I am getting to only calculate the time for each connection of the name but
    I am not getting to see the total time.
    Will it be that anybody could help?


    Frank Dulk Guest

  2. #2

    Default Re: calculate the time

    For such problems always post repro scripts (simplified CREATE TABLE
    statements, INSERT statements & expected results )

    Just guessing your requirements,

    SELECT name,
    SUM(DATEDIFF(second, BegTime, EndTime))
    FROM tbl
    GROUP BY name ;

    --
    - Anith
    ( Please reply to newsgroups only )


    Anith Sen Guest

  3. #3

    Default Re: calculate the time

    SELECT NOME, SOMARTEMPLIGACAO(CONVERT(CHAR, DATAFIMLIGACAO -
    DATAINICIOLIGACAO, 108)) FROM TABELA GROUP BY NOME.
    The format of the date that I would like is hh:mm:ss.


    "Anith Sen" <anithbizdatasolutions.com> escreveu na mensagem
    news:u#Kv6a9RDHA.2480tk2msftngp13.phx.gbl...
    > For such problems always post repro scripts (simplified CREATE TABLE
    > statements, INSERT statements & expected results )
    >
    > Just guessing your requirements,
    >
    > SELECT name,
    > SUM(DATEDIFF(second, BegTime, EndTime))
    > FROM tbl
    > GROUP BY name ;
    >
    > --
    > - Anith
    > ( Please reply to newsgroups only )
    >
    >

    Frank Dulk Guest

  4. #4

    Default Re: calculate the time

    my difficulty is to find the total value of the connections in the format
    hh:mm:ss. I get to find like this the time of the connections for each
    connection of the name:
    select convert(char, DHFimLigacao -DHInicioLigacao, 108) the TempoLigacao
    from controls.
    The one that I want is to add the total time of the connections contained by
    name in the format hh:mm:ss, and not the total time in minutes, or second. I
    go
    to research + a little and if I don't get, the way will be to place in that
    same format.


    "Anith Sen" <com> escreveu na mensagem
    news:u#phx.gbl... 


    Frank Guest

  5. #5

    Default Re: calculate the time

    To substract dates you have to use the DATEDIFF function. Not the
    mathematical minus (-) operation. Please see details about DATEDIFF function
    in SQL Server Books Online.

    --
    - Anith
    ( Please reply to newsgroups only )


    Anith Guest

Similar Threads

  1. How to calculate the time required for web method to serve the request.
    By Sonali Kulkarni via .NET 247 in forum ASP.NET Web Services
    Replies: 0
    Last Post: March 29th, 05:28 AM
  2. How to calculate elapsed time ?
    By Stuart Clemons in forum PERL Beginners
    Replies: 8
    Last Post: January 28th, 01:28 PM
  3. Calculate Field for Sick Time
    By Connie in forum Microsoft Access
    Replies: 1
    Last Post: July 30th, 04:39 PM
  4. Calculate elapsed time in minutes
    By Dave - Freedonia in forum Microsoft Access
    Replies: 0
    Last Post: July 29th, 04:40 PM
  5. Calculate Time
    By Dave Elliott in forum Microsoft Access
    Replies: 1
    Last Post: July 27th, 10:02 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139