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

Similar Messages

  • Calculating Elapsed Time Is Off By One Hour

    I am fully aware of many topics discussed in the various forums here related to the OS timezone and DST settings impacting how the JVM will process date/time calculations. I am running on Windows XP Professional, and I have checked and double checked the timezone setting, it is correctly set to Central Time and the "Automatically adjust clock for daylight saving changes" checkbox is checked.
    The code found at the end of this message clearly shows the problem for which I have yet to find an explination. I intended to be able to use a timer to update a string to show how much time has elapsed since the start of anything for which I need to know this information. As you can see by the results (example of which is listed after the code), the timezone and DST offsets seem to be properly retrieved by the JVM, but if this is the case, then why is the elapsed time value off by one hour?
    I am looking for a solution/explanation involving the date/time classes, not a workaround whereby I end up extracting multiple time representation subsets and manipulating them myself. Any help will be greatly appreciated.
    * TestTimeZone.java
    * Created on September 12, 2004, 7:18 PM
    import java.io.*;
    import java.util.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.text.*;
    * @author  Jared
    public class TestTimeZone {
        java.util.Date startDt;
        /** Creates a new instance of TestTimeZone */
        public TestTimeZone() {
         * @param args the command line arguments
        public static void main(String[] args) {
            new TestTimeZone().go();
        private void go() {
            startDt = new java.util.Date();
            TimeZone tz = TimeZone.getDefault();
            System.out.println("the default timezone is " + tz.getDisplayName(true, TimeZone.LONG));
            System.out.println("the default timezone ID is " + tz.getID());
            System.out.println("useDaylightTime = " + tz.useDaylightTime());
            System.out.println("default locale = " + Locale.getDefault().toString());
            javax.swing.Timer t = new javax.swing.Timer(1000, new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    java.util.Date currDt = new java.util.Date();
                    Calendar cal = Calendar.getInstance();
                    long elapsedTime = currDt.getTime() - startDt.getTime() -
                        (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET));
                    SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
                    System.out.println("Elapsed: " + formatter.format(new java.util.Date(elapsedTime)) +
                        " Start: " + formatter.format(startDt) +
                        " Current: " + formatter.format(currDt));
            t.start();
            while (true) try {
                Thread.sleep(10);
            } catch (Exception e) {
                e.printStackTrace();
    }And here is the result I am seeing:
    the default timezone is Central Daylight Time
    the default timezone ID is America/Chicago
    useDaylightTime = true
    default locale = en_US
    Elapsed: 23:00:01 Start: 00:03:57 Current: 00:03:58
    Elapsed: 23:00:02 Start: 00:03:57 Current: 00:03:59
    Elapsed: 23:00:03 Start: 00:03:57 Current: 00:04:00
    Elapsed: 23:00:04 Start: 00:03:57 Current: 00:04:01
    Elapsed: 23:00:05 Start: 00:03:57 Current: 00:04:02
    "

    Great. Now that we have gotten half way to the goal, please let me know how you intend to get that difference in miliseconds presented as a time value using any of the date/time classes Java has to offer. That way, I don't have to rewrite the code that puts it into a properly formatted String (the kind folks at Sun have already written that code). Using date/time classes to acheive this is what I attempted with my application. I added the milisecond adjustments for TZ and DST because if I didn't the reported elapsed time would be off by 6 hours, not just 1.
    I am open to all suggestions.

  • Oracle Performance 11g - Warning: log write elapsed time

    Hello ,
    We are facing quite bad performance with our SAP cluster running Oracle 11g .
    In the ora alert file we are having constant message for "
    Thread 1 cannot allocate new log, sequence xxxxxx
    Private strand flush not complete"
    However , this seems to be quite old as we have recently started facing the performace issue.
    Moreover , in the sid_lgwr_788.trc file we are getting warning for log write elapsed time as follow.
    *** 2013-07-25 08:43:07.098
    Warning: log write elapsed time 722ms, size 4KB
    *** 2013-07-25 08:44:07.069
    Warning: log write elapsed time 741ms, size 32KB
    *** 2013-07-25 08:44:11.134
    Warning: log write elapsed time 1130ms, size 23KB
    *** 2013-07-25 08:44:15.508
    Warning: log write elapsed time 1161ms, size 25KB
    *** 2013-07-25 08:44:19.790
    Warning: log write elapsed time 1210ms, size 10KB
    *** 2013-07-25 08:44:20.748
    Warning: log write elapsed time 544ms, size 3KB
    *** 2013-07-25 08:44:24.396
    Warning: log write elapsed time 1104ms, size 14KB
    *** 2013-07-25 08:44:28.955
    Warning: log write elapsed time 1032ms, size 37KB
    *** 2013-07-25 08:45:13.115
    Warning: log write elapsed time 1096ms, size 3KB
    *** 2013-07-25 08:45:46.995
    Warning: log write elapsed time 539ms, size 938KB
    *** 2013-07-25 08:47:55.424
    Warning: log write elapsed time 867ms, size 566KB
    *** 2013-07-25 08:48:00.288
    Warning: log write elapsed time 871ms, size 392KB
    *** 2013-07-25 08:48:04.514
    Warning: log write elapsed time 672ms, size 2KB
    *** 2013-07-25 08:48:08.788
    Warning: log write elapsed time 745ms, size 466KB
    Please advice to further understand the issue.
    Regards

    Hi,
    Seem the I/O issue, Check the metalink id
    Intermittent Long 'log file sync' Waits, LGWR Posting Long Write Times, I/O Portion of Wait Minimal (Doc ID 1278149.1)

  • Is there a data element for time unit (Hour, minute, second) and so forth)

    Thanks for your help.

    Hi Raja,
    I just want to add something in the drop down list
    'Hour'
    'Minute'
    'Second'
    I hope I can get these values from a domain value range.
    Could you please assist ?
    Anders

  • Displaying the hour, minute, seconds.....

    Hi fellow experts!
    Once again I call upon you for help. I'm strugglng with the formatting of dates...specifically the hour, minute, seconds between two dates.
    Sample data:
    create table test (script_name varchar2(50),run_start date,run_end date, job_id number, parent_job_id number);
    insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('IMPORTMTM','09-FEB-10','09-FEB-10','2409671','2409645');
    insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('INT_EOD_VALUATIONS','09-FEB-10','09-FEB-10','2409673','2409645');
    insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('ACC_EOD_FXACCOUNTING','09-FEB-10','09-FEB-10','2409677','2409645');
    insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('GLO_EOD_FXUPDATE ','09-FEB-10','09-FEB-10','2409679','2409645');
    insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('MX_PREACCOUNTING_BACKUP_RP','09-FEB-10','09-FEB-10','2409683','2409645');
    insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('DM_PREACCOUNTING_BACKUP_RP','09-FEB-10','09-FEB-10','2409684','2409645');
    insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('IMP_FIXING','09-FEB-10','09-FEB-10','2409688','2409645');
    insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('GLO_EOD_FIXINGIRD','09-FEB-10','09-FEB-10','2409690','2409645');
    insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('WAIT_5_MINS','09-FEB-10','09-FEB-10','2409692','2409645');
    The output of the time should look like the results from the query below:
    select floor((run_end-run_start)*24) as Hrs ,floor(((run_end-run_start)*1440 - floor((run_end-run_start)*24)*60)) as Mins,
    ceil(((run_end-run_start)*86400 - floor((run_end-run_start)*1440)*60)) as Secs
    from (
    select to_date('10-oct-2003 15:02:23','DD-Mon-YYYY HH24:Mi:SS') as run_start,
    to_date('10-oct-2003 16:20:20','DD-Mon-YYYY HH24:Mi:SS') as run_end
    from dual);
    i.e
    H M S
    1 17 57
    My current sql is:
    select script_name,
    run_start,
    run_end,
    floor((run_end-run_start)*24) as Hrs ,floor(((run_end-run_start)*1440 - floor((run_end-run_start)*24)*60)) as Mins,
    ceil(((run_end-run_start)*86400 - floor((run_end-run_start)*1440)*60)) as Secs
    from (
    select lpad(' ',5*level,' ')||name script_name
    ,to_date(run_start,'dd-mon-yyyy hh24:mi:ss') run_start, to_date(run_end,'dd-mon-yyyy hh24:mi:ss') run_end,
    sys_connect_by_path(to_date(run_start,'dd-mon-yyyy hh24:mi:ss'),'/') root_start
    from jcs_jobs
    connect by prior job_id = parent_job_id
    start with PARENT_JOB_ID IS NULL and job_id = 2409645
    I need a slight tweak somewhere, but can't quite get there!
    Oracle version is 9i
    Many thanks for your help in advance.
    Dev

    Hi,
    Devski Peters wrote:
    ......sorry, I didn't make myself clear.....Sorry, this message made things even less clear.
    Like Bhushan, I don't see any relationship between the data you posted:
    insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('IMPORTMTM','09-feb-2010 20:00:02','09-feb-2010 20:00:44','2409671','2409645');
    insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('INT_EOD_VALUATIONS','09-feb-2010 20:00:44','09-feb-2010 20:01:03','2409673','2409645');
    insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('ACC_EOD_FXACCOUNTING','09-feb-2010 20:01:05','09-feb-2010 20:01:24','2409677','2409645');
    insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('GLO_EOD_FXUPDATE ','09-feb-2010 20:01:24','09-feb-2010 20:01:43','2409679','2409645');
    insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('MX_PREACCOUNTING_BACKUP_RP','09-feb-2010 20:01:45','09-feb-2010 20:01:49','2409683','2409645');
    insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('DM_PREACCOUNTING_BACKUP_RP','09-feb-2010 20:01:45','09-feb-2010 20:01:49','2409684','2409645');
    insert into test (script_name,run_start,run_end,job_id,parent_job_id) values ('IMP_FIXING','09-feb-2010 20:01:51','09-feb-2010 20:02:15','2409688','2409645');and the results you want:
    NORMAL_DAY     09-feb-2010 18:05:00     10-feb-2010 04:22:45     20'681'879.88
    Step 1 of NORMAL_DAY     09-feb-2010 18:05:00     09-feb-2010 18:05:24     575.88
    Step 2 of NORMAL_DAY     09-feb-2010 18:05:24     09-feb-2010 18:05:46     527.88
    EOD_FX_RATE_UPLOAD     09-feb-2010 18:05:24     09-feb-2010 18:05:46     527.88
    Step 1 of EOD_FX_RATE_UPLOAD     09-feb-2010 18:05:24     09-feb-2010 18:05:30     143.88
    FX_FTPS_GET_EOD     09-feb-2010 18:05:26     09-feb-2010 18:05:30     95.88
    Step 2 of EOD_FX_RATE_UPLOAD     09-feb-2010 18:05:30     09-feb-2010 18:05:45     359.88
    FXSPOTS     09-feb-2010 18:05:31     09-feb-2010 18:05:45     335.88
    Step 3 of EOD_FX_RATE_UPLOAD     09-feb-2010 18:05:45     09-feb-2010 18:05:46     23.88
    SEND_MAIL_FXSPOTS     09-feb-2010 18:05:45     09-feb-2010 18:05:46     23.88
    Step 3 of NORMAL_DAY     09-feb-2010 18:05:46     09-feb-2010 18:06:10     1'535.88
    CALENDAR_UPLOAD     09-feb-2010 18:05:47     09-feb-2010 18:06:10     1'511.88
    Step 1 of CALENDAR_UPLOAD     09-feb-2010 18:05:47     09-feb-2010 18:05:53     143.88
    CALENDAR     09-feb-2010 18:05:47     09-feb-2010 18:05:53     143.88
    Step 2 of CALENDAR_UPLOAD     09-feb-2010 18:05:53     09-feb-2010 18:06:00     1'127.88
    MDS_STOP     09-feb-2010 18:05:53     09-feb-2010 18:06:00     1'127.88
    Step 3 of CALENDAR_UPLOAD     09-feb-2010 18:06:00     09-feb-2010 18:06:03     71.88
    MDS_HOLIDAY     09-feb-2010 18:06:00     09-feb-2010 18:06:03     71.88
    Step 4 of CALENDAR_UPLOAD     09-feb-2010 18:06:03     09-feb-2010 18:06:10     167.88Do you really want that data to produce that output?
    If the results are not from that data, then post a consistent set of data and results.
    When you have poted some sample data and the results you want from that data , explain how you get those results. Pick a couple of rows of output, and explain how you got every column in the results from the data. Be specific.
    The table has a 'pig ear' relationship......so job_id can have the same parent_job_id.....What is a "pig ear" relationship? (I like the name.)
    >
    The connect by allows me display the results with indentation, so the results will look like:The results look completely unformatted on my browser.
    When you post any formatted text on this site, type these 6 characters:
    (small letters only, inside curly brackets) before and after each formatted section.
    So for example,the first line shows a time of 20'681'879.88, which works out to 10:18 hours approx. Explain the relationship between 20'681'879.88 and "10:18 hours". (Do you mean 10 hours plus 18 minutes?)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • 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

  • 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();
    }

  • 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.

  • 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

  • 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

  • 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.

  • 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]...

  • Calcuate Hours: Minutes:Seconds between two dates excluding Weekends

    Hello All,
    @StartDate = '2014-06-21 13:37:30:037'
    @EndDate = GetDate()
    I want to find out Hours:Minutes:Seconds between the above dates EXCLUDING WEEKENDS.
    Please help.
    ReportingServices

    Hi,
    Give this a try:
    DECLARE @StartDate DATETIME = '2014-06-21 13:37:30:037'
    DECLARE @EndDate DATETIME = GETDATE()
    DECLARE @Base INT = 86400 -- ie Seconds in a days
    ;WITH cteCalculation AS (
    SELECT ((
    (DATEDIFF(dd, @StartDate, @EndDate) + 1)
    -(DATEDIFF(wk, @StartDate, @EndDate) * 2)
    -(CASE WHEN DATENAME(dw, @StartDate) = 'Sunday' THEN 1 ELSE 0 END)
    -(CASE WHEN DATENAME(dw, @EndDate) = 'Saturday' THEN 1 ELSE 0 END)
    ) * @Base)
    -(CASE WHEN DATENAME(dw, @StartDate) NOT IN ('Saturday', 'Sunday') THEN DATEPART(hh, @StartDate) * 3600 + DATEPART(mi, @StartDate) * 60 + DATEPART(ss, @StartDate) ELSE 0 END)
    -(CASE WHEN DATENAME(dw, @EndDate) NOT IN ('Saturday', 'Sunday') THEN @Base - (DATEPART(hh, @EndDate) * 3600 + DATEPART(mi, @EndDate) * 60 + DATEPART(ss, @EndDate)) ELSE 0 END)
    AS DiffInSec
    SELECT @StartDate
    ,@EndDate
    ,CAST(DiffInSec / 3600 AS VARCHAR(10)) + ':' +
    RIGHT('0' + CAST((DiffInSec % 3600) / 60 AS VARCHAR(2)), 2) + ':' +
    RIGHT('0' + CAST((DiffInSec % 3600 % 60) AS VARCHAR(2)), 2)
    FROM cteCalculation
    Feel free to modify to suit your needs!
    Hope this helps.
    ~J.

Maybe you are looking for

  • Hard drive and overall upgrades

    Hi so my HP Pavilion p6707c's hard drive has a failure emminent so i want to replace it and take this oportunity to upgrade other components in my tower. I would like to upgrade the hard drive, the RAM, the processor, and the graphics. I was wonderin

  • Auto fill subject with an Email link in CS4 Bridge flash web gallery

    Is there a way to autofill the subject line of the email link in the CS4 Bridge flab web galleries? I can do it if I use the html gallery, but I prefer the look of the flash galleries. If I open the "group.xml" file I see code for me email link, exp.

  • Recovery of lost non-system datafile

    Hello All, I have simulated a test environment where I have remove one of the non-sys datafile. For this first I have took the full database backup including archivelog and then remove the datafile from OS level. After that I manually created that da

  • Error in LDAP Server

    warning<20805> -Backend DataBase- conn=519183 op=0 msgId=1-search is not indexed. I am getting this error daily every time.I got the root cause for this error.I have increased the nsslapd-allidsthreshold value and nsslapd-dbcachesize.I am getting the

  • Color Adjust Filter and Paint Bucket not available in CS3

    I recently noticed that Colors in the Filter menu is not available in my install of Illustrator CS3. I also noticed that the Paint Bucket tool is missing. Both appear to be in the Plug-ins folder in their respective folders (Illustrator Filters and T