Convert seconds to Days, hours, Minutes, Seconds in Reporting Services

Hi Guys,
Im currently reporting of an analysis services cube, however I have value which is in seconds and would like to report on this in reporting services as day:HH:MM:SS.
Has anyone got any experience reporting in this format?
Regards
Dave

Hi Dave,
We can use custom code to convert seconds to HH:MM:SS
Public Function Calculate(ByVal TotalSeconds as Integer) as String
Dim Hours, Minutes, Seconds As Integer
Dim Hour, Minute, Second As String
Hours = floor(TotalSeconds/ 3600)
IF Hours<10
   Hour="0" & Hours.ToString
Else
   Hour=Hours.ToString
End IF
Seconds = TotalSeconds Mod 3600
Minutes =floor( Seconds / 60)
IF Minutes<10
   Minute="0" & Minutes.ToString
Else
   Minute=Minutes.ToString
End IF
Seconds = Seconds Mod 60
IF Seconds<10
   Second="0" & Seconds.ToString
Else
   Second=Seconds.ToString
End IF
Return Hour & ":" & Minute & ":" & Second
End Function
Then we can use the expression to conver it.
=Code.Calculate(Fields!Column.Value)
The report looks like below:
If you have any questions, please feel free to ask.
Regards,
Charlie Liao
If you have any feedback on our support, please click
here.
Charlie Liao
TechNet Community Support

Similar Messages

  • Adding day/hour/minute/second to a date value

    How does one add a day/hour/minute/second to a date value?

    SQL> select to_char(sysdate, 'DD/MM/YYYY HH24:MI:SS') to_day,
      2         to_char(sysdate+1, 'DD/MM/YYYY HH24:MI:SS') add_day,
      3         to_char(sysdate + 1/24, 'DD/MM/YYYY HH24:MI:SS') add_hour,
      4         to_char(sysdate + 1/(24*60), 'DD/MM/YYYY HH24:MI:SS') add_minute,
      5         to_char(sysdate + 1/(24*60*60), 'DD/MM/YYYY HH24:MI:SS') add_second
      6  from dual
      7  /
    TO_DAY              ADD_DAY             ADD_HOUR            ADD_MINUTE          ADD_SECOND
    10/10/2006 11:54:23 11/10/2006 11:54:23 10/10/2006 12:54:23 10/10/2006 11:55:23 10/10/2006 11:54:24
    SQL>Cheers
    Sarma.

  • Latest itunes shows silly days approximation instead of days, hours, minutes, seconds, how do i change back?

    itune 11.0.0.163 shows silly date approximation on bottom bar rather than days, hours, minutes, seconds as before. How do I change this?

    Apple buried the transfer purchases option, but it's still there. To transfer purchases from your iOS device in iTunes:
    Select the device toward the top-middle of iTunes (underneath the status area/progress bar/Apple logo).
    Go to the File menu.
    Select Devices
    Click on Transfer Purchases from [DeviceName]...

  • Convert Format Day, Hour, Minute, Seconds in Hours

    Hi all,
    I have one report generate by VoIP application like this:
    Total of hour has showed in Day (4). hour (20): Minute (26): seconds (06) summarize 4.20:26:06
    I need convert this format only how like 116 (hours) 26 (twenty six) Minutes 06 (Six) seconds. summarize 116:26:06
    How I can make this?
    Regards!
    Douglas Filipe http://douglasfilipe.wordpress.com

    Hi,
    I'm marking the reply as answer as there has been no update for a couple of days.
    If you come back to find it doesn't work for you, please reply to us and unmark the answer.
    Thanks
    George Zhao
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click "[email protected]"

  • Date difference in Days,hours minutes and seconds.

    Hi All,
    I have two date Suppose one is getdate() and other one is gatedate() +1 .I have to show the difference, currently I used a datediff in the stored proc which just shows the difference of the days :( but i need to show the difference in days:hours:minutes:seconds if possible.
    its a countdown with the current date. Like the two fields are sale_start_date and sale_end_date. Hope i am clear.
    Please let me know ASAP thanks in advance.Can anyone help me?all help is great help.
    Say the difference of
    12/6/2007 7:00:00 AM, 12/8/2007 8:00:00 AM  as 2 days 1:00:00)
    Thanks
    N

    One of the problems of using DATEDIFF when dealing with either seconds or milliseconds is that this function will result in execution errors if the start and end dates span then entire domain of possible dates.  Below is an alternative that seems to work over the entire date domain.  A couple of things to note:
    1. This select converts the days and seconds of each date into BIGINT datatypes to avoid the overflow error
    2. This select uses a CROSS APPLY operator; in this case I chose CROSS APPLY to suggest the possibility of converting this select into an inline table function.
    I suspect that if you dig around this forum and the net that you will find a better routine, but here is yet another alternative:
    declare @test table
    ( startDate datetime, endDate datetime)
    insert into @test values
    ('6/1/9', getdate()),
    ('6/9/9 15:15', '6/10/9 19:25:27.122'),
    ('6/9/9 15:15', '6/10/9 13:25:27.122'),
    ('6/9/9', '6/10/9 00:00:01'),
    ('1/1/1760', '12/31/2999')
    select
      startDate,
      endDate,
      [Days],
      [Hours],
      [Minutes],
      [Seconds]
    from @test
    cross apply
    ( select
        cast((endSecond - startSecond) / 86400 as integer) as [Days],
        cast(((endSecond - startSecond) % 86400) / 3600 as tinyint) as [Hours],
        cast(((endSecond - startSecond) % 3600) / 60 as tinyint) as [Minutes],
        cast((endSecond - startSecond) % 60 as tinyint) as [Seconds]
      from
      ( select
          86400 * cast(convert(integer, convert(binary(4),
                        left(convert(binary(8), startDate),4))) as bigint)
            + cast(convert(integer, convert(binary(4),
                right(convert(binary(8), startDate),4)))/300 as bigint)
          as startSecond,
          86400 * cast(convert(integer, convert(binary(4),
                        left(convert(binary(8), endDate),4))) as bigint)
            + cast(convert(integer, convert(binary(4),
                right(convert(binary(8), endDate),4)))/300 as bigint)
          as endSecond
      ) q
    ) p
    /* -------- Sample Output: --------
    startDate               endDate                 Days        Hours Minutes Seconds
    2009-06-01 00:00:00.000 2009-06-22 08:28:36.670 21          8     28      36
    2009-06-09 15:15:00.000 2009-06-10 19:25:27.123 1           4     10      27
    2009-06-09 15:15:00.000 2009-06-10 13:25:27.123 0           22    10      27
    2009-06-09 00:00:00.000 2009-06-10 00:00:01.000 1           0     0       1
    1760-01-01 00:00:00.000 2999-12-31 00:00:00.000 452900      0     0       0
    (5 row(s) affected)
     EDIT:
    I based the routine more-or-less on Thilla's reply.
    Kent Waldrop

  • Convert :-  Minutes to Days:Hours:Minutes

    Hi Friends ,
    I want to convert the time value from MINUTE to  HH : MM : SS  
    I mean in input i have to pass  200 Minutes and in Output i want to get the no of hr and minutes in the format  03 : 20  ( HH:MM) . I have used the FM "CONVERSION_EXIT_SDURA_OUTPUT" for this .
    This works fine for  time input values upto 5 digits  like  ( 20000 minutes) =  333:20 (HH:MM) ,
    when the input value is more than 5 digits , ex - 200000 this FM does not work .
    Is there any FM where i can get the conversion from MINUTE to HH :MM:SS  or from Minutes to DAYS :HPURS:MINUTES .
    I have searched SDN , but i dint get the exact FM which i want ,
    If any body has any idea on the same please guide me on the same .
    Regards
    Parbhudutta

    Thanks all for all of your valuable inputs .
    IBy using FM : MONI_TIME_CONVERT  , i am able to get  HH:MM:SS  format data by giving input as seconds .
    But the issues i have is , i have  data as input in seconds which is noear to a 10 digit number like
    200000000 seconds , which does not work  for this FM .
    I have input data in MINUTES which is near to 10 digit , exmp -  239879798 minutes . So i want to convert this no to ( DAYS : HOURS : MINUTES : SECONDS )
    Other FMs that has been given by you guys i have checked but i am not able to get exactly what i want .
    Anyway thanks again .
    Reagards
    Prabhudutta

  • How to show number of days:hours:min:second

    Hi !
    Need your help on this one:
    I have to calculate the number of (  Days;Hours:Minute:Second  ) that a ticket have been opened
    But I have a problem to display the format that I want:  DD:HH:MM:SS
    EX:the ticket have been opened 2011-05-03 11:00:00
    first I create a formula to show number of second to show how long the ticket have been opened since the currentDate in seconds
    Formula Name is:
    {@number of seconds OpeningTime}
    Crystal Syntax:
    DateTimeVar dt1:= {@DTOpenDate};
    DateTimeVar dt2:= {@CurrentDateTime};
    If dt2 >= dt1 Then
    NumberVar ds:= (Date(dt2) - Date(dt1))*86400; 
    NumberVar hs:= (Hour(dt2) - Hour(dt1))*3600; 
    NumberVar ms:= (Minute(dt2) - Minute(dt1))*60;
    Numbervar ss:= Second(dt2) - Second(dt1);
    NumberVar ts:= dshsms+ss)
    Else
    NumberVar ds:= (Date(dt2) - Date(dt1))*86400;
    NumberVar hs:= (Hour(dt2) - Hour(dt1))*3600;
    NumberVar ms:= (minute(dt2) - Minute(dt1))*60;
    NumberVar ss:= Second(dt2) - Second(dt1);
    NumberVar ts:= dshsms+ss)
    then I create another formula to display the format that I want:Ex:if the ticket have been opened for about 25hh:00mm:00ss
    i want to show 01:01:00:00
                             DD:HH:MM:SS
    Formula name: {@DTConversionOpeningTime}
    I use Crystal Syntax:
    WhilePrintingRecords;
    StringVar Days1;
    StringVar Hours1;
    StringVar Minutes1;
    StringVar Seconds1;
    NumberVar Duration:=0;
    Duration:= {@number of seconds OpeningTime};
    If Duration < 0 Then
      "Cannot have a time less than zero"
    Else
      (Days1:=ToText(Truncate(Duration/86400),0);
    Hours1:=ToText(Truncate(Duration/3600),0);
      Minutes1:=ToText(Truncate(Remainder(Duration,3600)/60),0);
      Seconds1:=ToText(Remainder(Remainder(Duration,3600),60),0));
    //Display format
      (if length(Hours1) < 2 then '0')+ Days1 + ":" +
      ["0",""][length(Hours1)]+ Hours1 + ":" +
      ["0",""][length(Minutes1)] + Minutes1 + ":" +
      ["0",""][length(Seconds1)] + Seconds1;
    Thanks for your help

    Find a solution, see thread:
    Re: Converting a calculated field into format of dd:hh:mm:ss answered by Jason Long

  • Converting seconds to Days,Hours,mins and secs

    Hi gurus,
    I have a metric in seconds , which is a box uptime . I want to convert that into Days,hours , mins and secs .How can I do that ?
    For example , If I have 433500 secs , I should show it as 5days 00:25:00 or in some meaningful format . Can anyone help me out ?
    Thanks,

    Hi,
    Refer thinks,
    Re: seconds to hh:mm:ss format
    OBIEE 11g - Change seconds to DD HH:MM:SS format
    Deva

  • Converting seconds to hours + minutes + seconds

    hey all,
    was just looking for the quickest way to convert seconds to hours + minutes + seconds
    eg, 18084 s is 5h, 1m, 24s.

    You can use the Apache Commons Lang DurationFormatUtils class
    import org.apache.commons.lang.time.*;
    public class SecondsConversion {
         public static void main(String[] args) {
              try {
                   int seconds = 18084;
                   int milliseconds = seconds * 1000;
                   String[] values = DurationFormatUtils.formatDuration(milliseconds, "H m s").split(" ");
                   System.out.println(values[0] + "h " + values[1] + "m " + values[2] + "s ");
              } catch (Exception e) {
                   e.printStackTrace();
    }

  • Write elapsed time to a spreadsheet in hours:minutes:seconds format

    Hi everyone,
    I've been trying to write an elapsed time to a spreadsheet file in an hours:minutes:seconds format, but the time is displayed in a floating point value of seconds..
    how can I write to a spreadsheet in an hours:minutes:seconds format.
    Thank you,
    James-

    I often use a subVI that converts Seconds to Hours, Minutes and Seconds. Use the Quotient and Remainder function to divide your elapsed time by 3600, 60 and 1. You can then convert those values to a modified string and use the Write to Spreadsheet File.
    As Dennis said, newer versions of LabVIEW's Write to Spreadsheet File.VI can handle arrays of Double, Integer or String automatically, and in older versions, the Write to Spreadsheet File.VI can be modified and copied to handle strings.
    Hope this helps.
    (Written in 8.5)
    Message Edited by LabViewGuruWannabe on 01-18-2008 09:28 PM
    Attachments:
    TimeToSpreadsheet.vi ‏26 KB
    SecondstoHMS.png ‏32 KB

  • FM for microseconds to  hours : minutes : seconds : microseconds conversion

    Hi Expart ,
                    Is there is any Fm to Convert  microseconds to  hours : minutes : seconds : microseconds. Actually i get the runtime in Micro second and i need to display it in above format .
    Please help me to get the fm or other simple way to do this
    Thanks
    Raju

    Hi,
    Use this link
    FM to converts seconds into HH:MM:SS
    Function Module for converting seconds into hours and minutes
    Hope these will help you.
    Regards,
    Vijay

  • Localized text for hour, minute, second, week, today, etc.

    You are able to get localized text for the weekday name, e.g. to get your localized name of "monday", use
    SimpleDateFormat sdf = new SimpleDateFormat("EEEE");
    String name = sdf.format(gregorianCalendar.getTime())for month names, you would use the format String MMMM:
    SimpleDateFormat sdf = new SimpleDateFormat("MMMM");Are there additional localized text available through some API? I'm looking for translations for "next", "previous", "day", "week", "month", "year", "hour", "minute", "second", "now", "today", "OK", "Cancel". (Of course, I could translate these myself and offer a MessageBundle, but if there are already translations down there through the API, why do work twice ;-)

    You are able to get localized text for the weekday name, e.g. to get your localized name of "monday", use
    SimpleDateFormat sdf = new SimpleDateFormat("EEEE");
    String name = sdf.format(gregorianCalendar.getTime())for month names, you would use the format String MMMM:
    SimpleDateFormat sdf = new SimpleDateFormat("MMMM");Are there additional localized text available through some API? I'm looking for translations for "next", "previous", "day", "week", "month", "year", "hour", "minute", "second", "now", "today", "OK", "Cancel". (Of course, I could translate these myself and offer a MessageBundle, but if there are already translations down there through the API, why do work twice ;-)

  • About year(), month(), date(), hour(), minute(), second() in Oracle

    In DB2, I can get the value of year, month, date, hour, minute, second from current timestamp by year(), month(), date(), hour(), minute(), second(). Like below SQL,
    SELECT current timestamp, year(current timestamp), month(current timestamp), date(current timestamp), hour(current timestamp), minute(current timestamp), second(current timestamp) FROM DUAL
    In Oracle, how can I modify above SQL?
    That is, do we have the corresponding function to each one of them in DB2?
    Thanks,
    JJ

    Hi Turloch,
    Thanks for your help.
    Here, I have another question.
    How about the days caculation?
    For example, in DB2, I have a SQL as below,
    select
    account_no
    from
    lit_transaction
    where
    ( start_date + no_of_days days - exp_days days) <= CURRENT DATE
    How can I modify above days caculation for Oracle?
    Thanks,
    J.

  • DatePicker: clear hours, minutes, seconds?

    Hi,
    I am using one date picker to compute the difference between two dates. In the Interface Builder I have declared the date picker as date only. But the date passed from the date picker to the NSDate field has hours, minutes, second on it. For some reason the hours, minutes, seconds is different from my first date to the 2nd date (shown below). For this calculation I am only interested in whole days and the hours, minutes, and seconds are getting in the way of my calculation. Is there any way to use only whole days, or to set the hours, minutes, seconds to zero before I call timeIntervalSince1970?
    NSDate *xbuydate = datePicker.date;
    NSLog(@"xbuydate : %@", xbuydate);
    buyElapsed = [xbuydate timeIntervalSince1970];
    NSLog result:
    5/26/09 3:49:18 PM AA-tab bar[596] xbuydate : 2000-01-01 17:00:00 -0700
    NSDate *xselldate = datePicker.date;
    NSLog(@"xselldate : %@", xselldate);
    sellElapsed = [xselldate timeIntervalSince1970];
    NSLog result:
    5/26/09 3:49:33 PM AA-tab bar[596] xselldate : 2007-12-31 15:49:22 -0700

    Hi, this is my version: -)
    @implementation NSDate(Utils)
    - (NSDate *)truncateToDay
    NSDate *result;
    if (self == nil) {
    return nil;
    } else {
    unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
    NSDateComponents *comps = [[NSCalendar currentCalendar] components:unitFlags fromDate:self];
    result = [[NSCalendar currentCalendar] dateFromComponents:comps];
    return result;
    Works without a problem so far.

  • Save date with precision (Hour, Minutes, seconds ) using V.O.

    Hi all,
    I'm using Jdeveloper 11g.
    I have an Entity object with a column called 'createdOn' of type Date and an entity based View Object with the same type.
    I'm trying to save today's Date with precision (day, month, year, hour, minutes, seconds) Using the view Object, but when I look in the Data Base, always appears the date without time.
    Here is my code in the application Module to save the data, I've tried some things but nothing...
    First I've tried using oracle.jbo.domain.Date, and I've tryed using Calendar as well. Nothing with
    ViewObjectImpl voSample = getSamples1View1();
    //Date creation for View Object
    oracle.jbo.domain.Date today = new Date(Date.getCurrentDate());
    //Calendar today = Calendar.getInstance();
    //loop through the list of samples (TESTGROUPTYPES), and create the objects
    while( it.hasNext())
    Row rowSample = voSample.createRow();
    SequenceImpl sequence = new SequenceImpl("SAMPLES_SEQ", voSample.getApplicationModule());
    rowSample.setAttribute("SampleId", sequence.getSequenceNumber());
    rowSample.setAttribute("CollectionId", stCollectionId);
    rowSample.setAttribute("TestgroupType",it.next());
    rowSample.setAttribute("UnitId",stUnitId);
    rowSample.setAttribute("SampleStatus", "ORDERED");
    rowSample.setAttribute("SampleBackup", "false");
    rowSample.setAttribute("CreatedOn", today);
    voSample.insertRow(rowSample);
    voSample.getApplicationModule().getTransaction().commit();
    Any help will be usefull,
    thanks in advance
    XAVI.

    Hello John,
    yes, I changed the date mask using
    alter session set NLS_DATE_FORMAT='DD/MM/YYYY-hh24:mi:ss'
    if i execute to_char(<date_column>, 'YY-MON-DD HH:MI:SS') on that column, the result is:
    09-MAY-27 12:00:00
    09-MAY-27 12:00:00
    09-MAY-27 12:00:00
    To launch the queries and see the results I'm using the JDeveloper's SQL WorkSheet.
    I can update the data and time and the time persists in the DB
    08-FEB-26 08:07:56
    so, i think there's something in hte EO, VO or App Module method that I'm doing wrong...
    The Entity Attribute is confirured:
    name: CreatedOn
    Type: Date
    Value type: literal
    Values checked: Persistent, Precision Rule and Queryable
    database column: CREATED_ON, type: DATE
    The View attribute is configured:
    Name: CreatedOn
    Type: Date
    Value type: Literal
    checked: Mapped to Column or SQL, Selected in query, queryable
    query column: Alias: CREATED_ON, Type: DATE

Maybe you are looking for

  • How to set an Application Item from PL/SQL

    I am attempting to set an Application Item After login to my app, I want to retrieve a row from my SETTINGS table and populate some Application Items with the settings information so that I can display some of that settings information on every page.

  • Apple TV - no audio

    I have a grewt picture but no audio, I'm on Mountain Lion, Hoem Sharing is on but nothing coming from my HDMI connection from Apple TV to my television. Any thoughts

  • Performance on Sybase Gateway

    Our case is when a row update on Oracle server. A trigger will fire and update a row on Sybase using gateway. We do a test, for first 1000 records, the speed is acceptable, but when over 1000, the speed drop and need 1 min to complete update one reco

  • Getting empathy to work

    I am new to arch linux. I just installed telepathy and all the protocol clients. I added a new account in gtalk, and it never seems to connect. Can someone guide me, i am pretty noob in all this. Thanking you, Mehrzad

  • EPMA Deploy Failed - Error : Shared instance of member

    Hello Experts, I have big problem, from time to time, I get shared members on my shared libary even tough I define all members as primary can any one advice how can I verfiy no shared members loaded to my shared libary? Thanks Ido Error : Shared inst