Sum of Time field

Dear Experts,
I've a field  which displays the minutes input to the HH.MM format.
Please help me in managing the SUM of this column in the same format. Presenlty I am getting in the decimal system.
(The above field type is in DEC 10 2 )
Regards
Jogeswara Rao
Moderator message: duplicate post.
Edited by: Thomas Zloch on Jun 16, 2011 9:39 AM

hi
thanks to all ,thanks a lot
at last the issue is solved ,i got a user defined function for padding .It seems there is no built in function for padding in SQL 2005.
if i am wrong please point out , so i think it is a helpful function  please check out  this ...
IF EXISTS (
       SELECT *
       FROM dbo.sysobjects
      WHERE id = object_id(N'[dbo].[fnPadLeft]')
        AND xtype IN (N'FN', N'IF', N'TF')
  DROP FUNCTION [dbo].[fnPadLeft]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE FUNCTION fnPadLeft
  @PadChar char(1),
  @PadToLen int,
  @BaseString varchar(100)
RETURNS varchar(1000)
AS
  Author:       Daniel Read
  Description:   
    Pads @BaseString to an exact length (@PadToLen) using the
    specified character (@PadChar).  Base string will not be
    trimmed. Implicit type conversion should allow caller to
    pass a numeric T-SQL value for @BaseString.
    Unfortunately T-SQL string variables must be declared with an
    explicit width, so I chose 100 for the base and 1000 for the
    return. Feel free to adjust data types to suit your needs.
    Keep in mind that if you don't assign an explicit width to
    varchar it is the same as declaring varchar(1).
  Revision History:
  Date    Name  Description
BEGIN
  DECLARE @Padded varchar(1000)
  DECLARE @BaseLen int
  SET @BaseLen = LEN(@BaseString)
  IF @BaseLen >= @PadToLen
    BEGIN
      SET @Padded = @BaseString
    END
  ELSE
    BEGIN
      SET @Padded = REPLICATE(@PadChar, @PadToLen - @BaseLen) + @BaseString
    END 
  RETURN @Padded
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

Similar Messages

  • Finding sum for time field in alv

    hi gurus.,
              i need to find total hours.. i am using field of data type 'TIMS' ... i converted the value to decimal in ALV and founfd total hours .. i need the total hours in Time format .. how can i achieve this in alv .. its very urgent ...
    thanks&regards.,
    S.Sivakumar

    Hi Shivakumar,
    I suggest you not to convert TIMS to Decimal
    because it won't give you correct result..
    Eg...
    Time1 = '11:56:32'
    Time2 = '11:50:10'        
    now add these two times...
    u will get the sum of these as 23:06:42
    but in real life... you want the result as 23:46:42
    So the better way for getting accurate result is to convert this
    HH:MM:SS to Seconds
    and then sum these seconds
    then again convert it to HH:MM:SS
    1 hr = 3600 sec
    1 min = 60 sec
    Hope it will solve your problem...
    Reward points if useful...
    Thanks & Regards
    ilesh 24x7

  • Can i sum time fields?? (i expect that yes....)

    Hi everybody.
    I'm a visual basic programmer, actually, visual studio 2005, now i beginning with crystal report for visual studio 2005, nice and easy to use with the wizard, but,,, if i want to do something i little bit complex i can't find a manual for beginners.
    Now Iu2019m trying to do a report that list fields from a typed dataset, that dataset contains same datetime fields i.e. 1:30 , I put that fields in the details region, all it's ok, but the problem became when i try to sum all the times and totalize then.  The reason (i supposed) it's that the4 crystal can't sum time fields.
    Thinking about this, i suppose that i can do something with code but i can't find nothing about this, Can anybody tell me where is a manual to code in crystal report?
    Well, if somebody have any idea please tell me.

    The Crystal syntax doesn't change much from version to version so you can look at our SDK Guide on Diamond.
    http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/devsuite.htm
    http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/en/CrystalReports_dotNET_SDK/crsdk_net_doc/doc/crsdk_net_doc/html/crconformulareference.htm
    If you really want to formula reference for Crystal Reports for Visual Studio .NET 2005 you can look here [http://msdn.microsoft.com/en-us/library/ms225334(VS.80).aspx|http://msdn.microsoft.com/en-us/library/ms225334(VS.80).aspx].
    Edited by: David Hilton on Sep 29, 2008 4:47 PM
    Edited by: David Hilton on Sep 29, 2008 4:48 PM

  • Dump when summing up CURR field in ALV GRID display

    Hi All,
    I am getting dump when I try to sum the CURR field in my ALV Grid Display. The field is of CURR 23.  I am using classes and methods to display alv grid.
    I tried passing <fs_fieldcat>-do_sum = 'X'. When I did this, it is dumping without even displaying the alv grid.
    Here is the part it is throwing dump:
            ls_lvc_data-value = space.
            clear ls_lvc_data-style.
            loop at it_fcat_local assigning <ls_fcat>
                    where tech ne 'X' and no_out ne 'X'.
              if l_invisible eq 'X'.
                clear l_invisible.
                if <ls_fcat>-do_sum is initial.
                  continue.
                else.
                  clear ls_lvc_data-col_pos.
                endif.
              endif.
              add 1 to ls_lvc_data-col_pos.
              assign component <ls_fcat>-fieldname
                               of structure <ls_data> to <l_field_value>.
              _if sy-subrc ne 0.
                message x000(0k).
              endif._
    Regards,
    Guru

    Thomas,
    Here is the dump:
    Runtime Errors         MESSAGE_TYPE_X
    Date and Time          10/22/2010 23:30:53
    Short text
    The current application triggered a termination with a short dump.
    What happened?
    The current application program detected a situation which really
    should not occur. Therefore, a termination with a short dump was
    triggered on purpose by the key word MESSAGE (type X).
    Error analysis
    Short text of error message:
    Long text of error message:
    Technical information about the message:
    Message class....... "0K"
    Number.............. 000
    Variable 1.......... " "
    Variable 2.......... " "
    Variable 3.......... " "
    Variable 4.......... " "
    How to correct the error
    Probably the only way to eliminate the error is to correct the program.
    If the error occures in a non-modified SAP program, you may be able to
    find an interim solution in an SAP Note.
    If you have access to SAP Notes, carry out a search with the following
    keywords:
    "MESSAGE_TYPE_X" " "
    "SAPLSLVC" or "LSLVCF36"
    "FILL_DATA_TABLE"
    If you cannot solve the problem yourself and want to send an error
    notification to SAP, include the following information:
    1. The description of the current problem (short dump)
    To save the description, choose "System->List->Save->Local File
    (Unconverted)".
    2. Corresponding system log
    Display the system log by calling transaction SM21.
    Restrict the time interval to 10 minutes before and five minutes
    after the short dump. Then choose "System->List->Save->Local File
    (Unconverted)".
    3. If the problem occurs in a problem of your own or a modified SAP
    program: The source code of the program
    In the editor, choose "Utilities->More
    Utilities->Upload/Download->Download".
    4. Details about the conditions under which the error occurred or which
    actions and input led to the error.
    Source Code Extract
    Line
    SourceCde
    2708
    is_subtottxt_info = ls_subtot_info
    2709
    ip_subtot_line    = lr_data
    2710
    changing
    2711
    c_subtottxt       = l_subtottxt.
    2712
    ls_lvc_data-value = l_subtottxt.
    2713
    2714
    append ls_lvc_data to ct_lvc_data.
    2715
    endif.
    2716
    2717
    2718
    Column per Fieldcat Entry
    2719
    2720
    ls_lvc_data-value = space.
    2721
    clear ls_lvc_data-style.
    2722
    loop at it_fcat_local assigning <ls_fcat>
    2723
    where tech ne 'X' and no_out ne 'X'.
    2724
    if l_invisible eq 'X'.
    2725
    clear l_invisible.
    2726
    if <ls_fcat>-do_sum is initial.
    2727
    continue.
    2728
    else.
    2729
    clear ls_lvc_data-col_pos.
    2730
    endif.
    2731
    endif.
    2732
    2733
    add 1 to ls_lvc_data-col_pos.
    2734
    2735
    assign component <ls_fcat>-fieldname
    2736
    of structure <ls_data> to <l_field_value>.
    2737
    if sy-subrc ne 0.
    >>>>>
    message x000(0k).
    2739
    endif.
    2740
    2741
    *... work on average
    2742
    if <ls_fcat>-do_sum eq 'C'.
    2743
              Initialize average result and entries
    2744
    <l_field_value> = 0.
    2745
    clear l_entries.
    2746
    2747
              retrive unit from fieldcatalog
    2748
    assign space to <l_unit>.
    2749
    if not <ls_fcat>-cfieldname is initial.
    2750
    assign component <ls_fcat>-cfieldname
    2751
    of structure <ls_data> to <l_unit>.
    2752
    endif.
    2753
    if not <ls_fcat>-qfieldname is initial.
    2754
    assign component <ls_fcat>-qfieldname
    2755
    of structure <ls_data> to <l_unit>.
    2756
    endif.
    2757

  • Sum Date Time data type

    hello,
    In rdlc report i need to sum the date time datatype .
    please help .
    thanks.

    Hi Krishnakumar_Dev,
    If we want to extract hour in a date time field, we can use hour function as below in Reporting Services.
    =sum(hour(Fields!date.Value))
    Besides, if this issue is still existed, Could you please post the screenshot about your dataset with sample data and desired result?
    For more information about Date and Time Functions, please refer to the following link:
    http://technet.microsoft.com/en-us/library/aa337153(v=sql.100).aspx
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Sum a DATETIME field

    Just noticed it isn't straight forward to SUM a DATETIME fields.
    I’ve used the following code to get the time, how do I convert the output back to a DATETIME field?
    declare @T table
    total_hours_worked datetime
    insert into @T values ('01:00:00')
    insert into @T values ('01:30:00')
    insert into @T values ('03:35:00')
    select *
    from @T
    select SUM((DATEPART(hh,total_hours_worked)*60)+DATEPART(mi,total_hours_worked)+(DATEPART(ss,total_hours_worked)/(60.0)))/60.0 as TotalHours from @T
    Thanks,

    I should have added the disclaimer that my solution would require total_hours_worked to be stored as either a float or a varchar to be used with the function I described above.   The completed functions would be similar to 
    CREATE FUNCTION dbo.TimeSpan_CreateFromString
    @pFormattedTimeSpan varchar(128) = null
    RETURNS float(53)
    with returns null on null input AS
    BEGIN
    declare @DayPortion int
    ,@HourPortion int
    ,@MinutePortion int
    ,@SecondPortion decimal(6,4)
    declare @l int
    declare @s2 varchar(128)
    DECLARE @Result float(53)
    select @s2=LTRIM(rtrim(@pFormattedTimeSpan))
    set @l = LEN(@s2)
    declare @i int
    if CHARINDEX('.',@s2,1) < CHARINDEX(':',@s2,1)
    begin
    set @i = CHARINDEX('.',@s2,1)
    select @DayPortion =
    case CHARINDEX('.',@s2)
    when 0 then 0
    else
    case ISNUMERIC(SUBSTRING(@s2,1,CHARINDEX('.',@s2)-1))
    when 1 then CAST(SUBSTRING(@s2,1,CHARINDEX('.',@s2)-1) as int)
    else 0
    end
    end;
    set @s2=ltrim(rtrim(SUBSTRING(@s2,@i+1,@l-(@i))))
    end
    else
    begin
    set @DayPortion=0
    end
    -- ** debug: select @i, @l, @s2
    --select CHARINDEX(':',@s2,1) [c1], CHARINDEX(':',@s2,CHARINDEX(':',@s2,1)+1) [c2], CHARINDEX(':',@s2,(CHARINDEX(':',@s2,CHARINDEX(':',@s2,1)+1))+1) [c3]
    set @i = CHARINDEX(':',@s2,1)
    select @HourPortion =
    case CHARINDEX(':',@s2,1)
    when 0 then 0
    else
    case ISNUMERIC(SUBSTRING(@s2,1,CHARINDEX(':',@s2,1)-1))
    when 1 then CAST(SUBSTRING(@s2,1,CHARINDEX(':',@s2,1)-1) AS int)
    else null
    end
    end
    set @s2=ltrim(rtrim(SUBSTRING(@s2,@i+1,@l-(@i))))
    -- ** debug: select @i, @l, @s2
    set @i = CHARINDEX(':',@s2,1)
    select @MinutePortion =
    case CHARINDEX(':',@s2,1)
    when 0 then 0
    else
    case ISNUMERIC(SUBSTRING(@s2,1,CHARINDEX(':',@s2,1)-1))
    when 1 then CAST(SUBSTRING(@s2,1,CHARINDEX(':',@s2,1)-1) AS int)
    else null
    end
    end
    set @s2=ltrim(rtrim(SUBSTRING(@s2,@i+1,@l-(@i))))
    -- ** debug: select @i, @l, @s2
    set @i = CHARINDEX(':',@s2,1)
    select @SecondPortion =
    case ISNUMERIC(@s2)
    when 0 then null
    else CAST(@s2 as decimal(6,4))
    end
    SELECT @Result = dbo.TimeSpan_CreateFromParts(@DayPortion,@HourPortion,@MinutePortion,@SecondPortion);
    RETURN @Result
    END
    GO
    I changed the function names to make them more consistent.

  • Sum of Time

    Dear All,
    I want to sum up of the Time field in Crystal Report. For example I have times as 8.30, 8.30, 9.30, 10.00, 8.30. So the sum should be shown as 44.20. How to achieve this in crystal report.
    Regards,
    Kamlesh

    Do you require to show sum as 44.20 or 45.00?
    in case of showing 45 hours
    create formulas
    1. hrs : DatePart('H',  )
    2. minutes : DatePart('M',  )
    3. Sum : totext( Sum ({@hrs})+ INT(Sum ({@minute})/60),0,"")&":"&totext(remainder( Sum ({@minute}),60),"00")
    Jyothi
    Edited by: Jyothi Yepuri on Sep 10, 2009 2:13 AM

  • Sum of a field in ALV List

    Hello Guys,
    I'm using 'REUSE_ALV_GRID_DISPLAY' in my prog.
    There is a field in output table which is of type P(8) Decimals 3.
    When I'm trying to get the sum of this field in ALV Display it gives the message " Desired operation cannot be performed for column 'Converted Quantity' ".
    I have also tried do_sum = 'X'.
    But it is not working. Please help guys.
    Regards,
    Abhinav

    Thanks a lot guys for your inputs.
    The program is working now.
    Now I'm using :
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname = 'QUAN'.
    *  wa_fieldcat-ref_tabname = 'I_OUT2'.
    *  wa_fieldcat-tabname = 'I_OUT2'.
      wa_fieldcat-qfieldname = 'MEAS'.
      wa_fieldcat-qtabname = 'I_OUT2'.
      wa_fieldcat-outputlen = '15'.
      wa_fieldcat-seltext_l = text-052.
      APPEND wa_fieldcat TO i_fieldcat.
    The program is working fine now.
    I have commented tabname and -ref_tabname , and the program is working fine now.
    Thanks a lot.

  • SUM for a field in ALV

    Hello Guys,
    CAn any one tell me how to do the SUM for a particular column in ALV.It should display at the End of the records.The column field is TYPE N(4).
    My CODE is like this:
    CLEAR fc_tmp.
      fc_tmp-col_pos         =  5.
      fc_tmp-reptext_ddic    = 'POINTS'.
      fc_tmp-fieldname       = 'POINTS'.
      fc_tmp-tabname         = 'ITAB'.
      fc_tmp-outputlen       = 15.
      fc_tmp-key             = 'X'.
      fc_tmp-do_sum          = 'X'.
      APPEND fc_tmp TO fieldcat.
    This is not working.
    Thanks in Advance,
    Take care

    Hi,
    populate the IT_SORT internal table of REUSE_ALV_GRID_DISPLAY provided in the importing parameters.
    fieldname = Company Code
    append fieldname to it_sort.
    fieldname = division.
    append fieldname to it_sort.
    If you explicitly need subtotals then add the following line
    subtot = 'X'
    For obtaining sum you have an attribute "do_sum" in fieldcatalog , set it to 'X' and you should be able to do sum on that field.
    <b>Ensure that these should be numeric / currency or quantity datatypes only.</b>
    wa_fieldcat-datatype = 'CURR'.   or
    wa_fieldcat-datatype = 'QUAN'.
    Hope this solves your problem
    Cheers,
    Simha.
    PS : Please reward points if solution is helpful

  • Time field in alv list

    Hi all ,
    i want to display alv list with time field . if no data exists in that field its showing 00:00:00 , i have to show it blank. if i change time field as type c in my internal table its showing like this 121314, i need to display it 12:13:14 . if no data it should display balnk . can any one help me out to reslove this issue?

    Hi priya,
    do this:
    declare in your itab a field like sy-uzeit.
    as example.
    move sy-uzeit to itab-uzeit.
    In fieldcat do this:
        MOVE  'X'                        TO   WA_FIELDCAT-NO_ZERO.
    Hope it helps.
    regards, Dieter

  • How to show a time field in a form portlet

    Hi,
    I am not familiar with PL/SQL and I was wondering how I could show a time field on a form portlet.
    I have a date column in my database that stores the time and date together, but I do not know how to separate them into date and time fields. I also do not know how to concatenate them when a user inserts a new record, or how to query on a date alone.
    At present, the user has to type the date and time following this format mask hh:mi am DD/Mon/RR
    I also have a problem with one of my hidden id fields. I have set the default to a sequence.nextval (#qtc_app.seq_visitor.nextval) and then hidden it since
    it is irrelevant to my users. However, I can no longer use the query function since the sequence is always generating a new value. How would I only generate
    a new sequence no. when a user inserts a record??
    Thank you!
    cheers, Kim

    Hi,
    Each colunm in the form has a format mask associated with it. For the date column make the format mask like this DD-MON-RR HH.MI. This will show the date along with the hours and minutes.
    Thanks,
    Sharmila

  • F4 help for Time field in Webdynpro Screen

    Hi Experts,
    I'm using TIMS data type for my Time field. In ECC we will have F4 function for the same data element, but in Webdynpro screen, am not getting the F4 help.
    I got some information from SCN that I need to go for some custom search help. But with which reference to the table, am I want to create it.
    Please let me know, is there any other possible way to create F4 for time field for webdynpro.
    Even I tried to use some standard search help, but am getting an error as 'Sending of dynpro ' ' not possible. No window system type specified'.
    Expecting valuable information from you experts.
    With Regards,
    RAM.

    Hi RAM,
    For time field, there is no SAP delivered search help in WDA , so we need to go for freely programmed search help.
    Please refer the below link, in which Mr. Thomas, has provided the links for search help document you can follow and create new search help component
    and also nugget of the component which can be imported using ZSAPLINK program.
    search help for time
    Regards,
    Rama

  • No time field in an event added by pressing down a date in the month view of the calendar!, no time field in an event added by pressing down a date in the month view of the calendar!

    I have been trying to add time to an event i already added but the time field does not exist.
    this happens only when I add the event from the month view while I press a date. in no other senario does this happens.
    may be its a bug in the calendar.
    if I press the + sign then it's normal.
    any suggestions on how to fix this?

    there is edit button; however, my problem comes after that. if the event was added using the above method then there is still no way to change the time of the event in that date. if the event was added in any other way then I can change the time.
    and I just realized my iphone3gs with ios5.0.1 has the same exact bug.

  • Material description filled automatically as the sum of two fields

    Hello to all
    We can automate the process of the creation a new material doing that the field material description(MAKT-MAKTX) can be filled by the system before saving(not by the user) as the sum of two fields in the MARA table that the users will be filled manually.
    Is it possible using a user exit, field exit,....?
    Thanks in advance.
    Regards

    Hello to all
    We can automate the process of the creation a new material doing that the field material description(MAKT-MAKTX) can be filled by the system before saving(not by the user) as the sum of two fields in the MARA table that the users will be filled manually.
    Is it possible using a user exit, field exit,....?
    Thanks in advance.
    Regards

  • How can I query on a time field??

    Hi All,
    I have a time field (base table field) in my form. I use a format mask of HH24:MI for that field.
    If i put in "%10:00" in that field and query, the query returns rows correctly. But I canot ask my user to put in a "%" each time he/she queries. I have to do it from the form.....
    How can I do this programatically..I mean how do I write it in pre-query?
    Thanks in advance...
    Sowmya.

    Hi,
    Thanks for your reply...
    Unfortunately I already tried that..
    The problem was to compare only the time portions . And as soon as the user put in say "12:00" in the time field, the system defaulted it to 01-SEP-2002 12:00:00 .And it compared this to the database value which is wrong...
    I solved the problem by creating a non-base table item and then writing code in pre-query using set_block_property etc...and it worked !!
    Thanks for you response once again..
    Sowmya.
    How about using the Set_block_property(Default_where) built in? check the online help.

Maybe you are looking for

  • Iphoto 6 not updating

    Hi,I have just installed an update from apple dvd.From os 10.4 to os 10.6.8.Everything except iphoto has updated.I am still running iphoto 6 .I have done software update online and it tells me that everything is upto date. Any ideas? Thanks

  • Some third Party Applications have suddenly stopped working

    My Onyx, ClamXav. Tiger Cache Cleaner and Speed Download have suddenly stopped opening when I click the application. Eudora, Firefox, NeoOffice, Quicken and MT Newswatcher still function normally. I can't download anything, probably because Speed Dow

  • Need help with self join query

    Hello, I have table A with the following data oid parent_oid 10 4 4 2 2 2 12 6 6 6 parent_oid is the parent of oid. I'd like a query that shows the final parent of the oid. The result should show the following oid final parent 10 2 4 2 2 2 12 6 6 6 I

  • TP4 Install problems

    I am trying to install TP4 on WIndows 2003 Server (VM) and am running into issues. I am also running database v11.1.0.6. I realize this is officially unsupported, but I'm not going to run a whole separate database stack. I need 11g. I appreciate any

  • To register with iTunes Connect, I require a URL?, To register with iTunes Connect, I require a URL?

    To register on iTunes Connect, I require a URL? What does this mean?