Rounding time field to nearest half hour

Post Author: fiscyn
CA Forum: Formula
Is there a way to round a time field?
For example,  if a time field is from 9:01 to 9:14  I want it to round back to 9:00;  
9:15 to 9:29  or 9:31 to 9:44   I want either option to round to 9:30
and 9:45 to 9:59 I want to round to 10:00.
  I want to keep the original time and have the rounded time listed next to it.    Also I want this for a 24 hour clock, military time.  Don't know if that makes a difference.
Any help is appreciated.
Thanks.

Post Author: fiscyn
CA Forum: Formula
I'm slowly getting this to work.    Just a couple problems,  minor I hope.
I used the CTime function and used the rounding formulas for minutes and hours as you suggested.  It works great.   But the results for the hours come out as 12.00  and the minutes as 30.00 or 0.00.   How do I drop the decimals?   I tried the totext, 0 function,  but the numbers don't line up correctly.   If the hour is 9.00,  it drops the zero place holder.   So if 9 and 10 are lined up,  the 9 is above the 1 instead of the 0.  
  It works fine for the minutes except I end up with 0 instead of 00.   Any suggestions?
I greatly appreciate the help so far.   Thank you.

Similar Messages

  • Rounding time to nearest hourly quarter

    I have several records like
    2/19/2010 1:25:46.000000 PM
    2/19/2010 1:40:46.000000 PM
    2/19/2010 1:55:46.000000 PM
    2/19/2010 2:10:46.000000 PM
    I want to round them off to the nearest quarter like
    2/19/2010 1:30:00.000000 PM
    2/19/2010 1:45:00.000000 PM
    2/19/2010 2:00:00.000000 PM
    2/19/2010 2:15:00.000000 PM
    Any ideas how I would do that? a trunc(col,'mi) only lets me round it to the minute..
    Note that records are not necessarily in the 5 minute interval difference it can also be 7 minute difference or 4 minute difference from the nearest quarter...
    so I can also have records like
    SysUpTime     2/19/2010 10:31:00 PM
    SysUpTime     2/19/2010 10:57:00 PM
    SysUpTime     2/19/2010 11:31:00 PM
    etc.
    Edited by: zebango on Mar 9, 2010 4:16 PM

    Solomon Yakobson wrote:
    But OP asked for "*Rounding* time to nearest hourly quarter". Same applies to Aketi's solution which, BTW, which always bumps it up to next 5 min.In which case, just substitute "Round" for "Floor"!
    Although thinking about it, you'd probably want to add seconds into the mix:
    with table_x as (select to_timestamp('11/03/2010 11:45:39', 'dd/mm/yyyy hh24:mi:ss') t from dual union all
                     select to_timestamp('11/03/2010 11:52:29', 'dd/mm/yyyy hh24:mi:ss') t from dual union all
                     select to_timestamp('11/03/2010 11:52:30', 'dd/mm/yyyy hh24:mi:ss') t from dual union all
                     select to_timestamp('11/03/2010 11:52:31', 'dd/mm/yyyy hh24:mi:ss') t from dual union all
                     select to_timestamp('11/03/2010 12:00:01', 'dd/mm/yyyy hh24:mi:ss') t from dual union all
                     select to_timestamp('11/03/2010 12:07:29', 'dd/mm/yyyy hh24:mi:ss') t from dual union all
                     select to_timestamp('11/03/2010 12:07:31', 'dd/mm/yyyy hh24:mi:ss') t from dual union all
                     select to_timestamp('11/03/2010 13:22:10', 'dd/mm/yyyy hh24:mi:ss') t from dual union all
                     select to_timestamp('11/03/2010 13:22:40', 'dd/mm/yyyy hh24:mi:ss') t from dual)
    select t,
           trunc(t, 'hh') + ROUND((to_char(t, 'mi') + (to_char(t, 'ss')/60))/15)*15/1440 nearest_15_min
    from   table_x
    T                                NEAREST_15_MIN      
    11/03/2010 11:45:39.000000       11/03/2010 11:45:00 
    11/03/2010 11:52:29.000000       11/03/2010 11:45:00 
    11/03/2010 11:52:30.000000       11/03/2010 12:00:00 
    11/03/2010 11:52:31.000000       11/03/2010 12:00:00 
    11/03/2010 12:00:01.000000       11/03/2010 12:00:00 
    11/03/2010 12:07:29.000000       11/03/2010 12:00:00 
    11/03/2010 12:07:31.000000       11/03/2010 12:15:00 
    11/03/2010 13:22:10.000000       11/03/2010 13:15:00 
    11/03/2010 13:22:40.000000       11/03/2010 13:30:00 

  • Why doesn't siri know how to change the time of a reminder? When asked, "Do you want to confirm or cancel your reminder?" Reply, "Can I change the time to a half hour later?" Siri doesn't know how to respond.

    Why doesn't siri know how to change the time of a reminder? When asked, "Do you want to confirm or cancel your reminder?" Reply, "Can I change the time to a half hour later?" Siri doesn't know how to respond.

    Hi
    In iMovie'11 (version 9.0.x)
    on top menu row - Apple/iMovie/File/Edit/Cut (Can vary dep. on language - in Swedish Apple/iMovie/Arkiv/Redigera/Klipp . . . )
    down Cut menu - Slow playback/Raspid Playback/Re-play in Slow Motion and onvards
    Here one can select the Pre-Set speeds
    Are you familiar with getting 'inspector' to run?
    No - but I guess that Double Click on clip/sequense or ctrl-Click on it might open it.
    Yours Bengt W

  • Itunes stops working after say half hour of use and will not play next song, the only way to get it working again is to close and reopen, then it works fine till next time, but the problem keeps returning

    itunes stops working after say half hour of use and will not play next song, I have to close and reopen, it works fine till next time, it keeps happening on a regular basis, HP pavilion laptop, g6 series,
    Window 7 64 bit

    Hello davewood26,
    The following article provides steps that can help get iTunes stabilized.
    iTunes for Windows Vista, Windows 7, or Windows 8: Fix unexpected quits or launch issues
    http://support.apple.com/kb/TS1717
    Cheers,
    Allen

  • Add 1 hour to date/time field in list

    I need some help understanding the Date/Time fields in SharePoint Online. I've created a list with 2 date/time fields... StartDate and EndDate. I want the StartDate field to default to the current date/time. I want the EndDate field to default to the current
    date/time + 1 hour. I've tried numerous formulas in the default calculated value for these fields, and couldn't get it right. I finally got it, but I don't understand why. Here is the scenario:
    ***Note: Time Zone is set to UTC+5 (EST). Current Time is 8:45am
    Attempt 1:
    StartDate - Selected "Today's Date" for the Default Value
    EndDate - Selected "Calculated Value" for the Default Value. Entered the formula
    =now()+TIME(1,0,0) 
    Actual Results - StartDate: 5/28/2014 9:00am  EndDate: 5/28/2014 6:45am
    Attempt 2:
    StartDate - Selected "Calculated Value" for the Default Value. Entered the formula
    =now()
    EndDate - Selected "Calculated Value" for the Default Value. Entered the formula =now()+TIME(4,0,0) 
    Actual Results - StartDate: 5/28/2014 5:45am  EndDate: 5/28/2014 9:45am
    Attempt 3:
    StartDate - Selected "Calculated Value" for the Default Value. Entered the formula =now()+TIME(3,0,0)
    EndDate - Selected "Calculated Value" for the Default Value. Entered the formula =now()+TIME(4,0,0) 
    Actual Results - StartDate: 5/28/2014 8:45am  EndDate: 5/28/2014 9:45am
    So on attempt 3, I finally got the results that I was looking for. However, I don't understand a couple things:
    1. Why does selecting "Today's Date" for the default value, not select the current time?
    2. Why do I needed to offset the hours by 3 to get the current time?
    Thanks in advance,
    cflbasser

    The now function in my environment gives me the time in which the server is housed. If I change the regional settings it does not have an effect on the time. I'm guessing this means that your server is hosted in the UK or somewhere near there and the regional
    settings don't have an effect.
    Andy Wessendorf SharePoint Developer II | Rackspace [email protected]

  • How do you calculate difference in time (hours and minutes) between 2 two date/time fields?

    Have trouble creating formula using FormCalc that will calculate difference in time (hours and minutes) from a Start Date/Time field and End Date/Time field. 
    I am using to automatically calculate total time in hours and minutes only of an equipment outage based on a user entered start date and time and end date and time. 
    For example a user enters start date/time of an equipment outage as 14-Oct-12 08:12 AM and then enters an end date/time of the outage of 15-Oct-12 01:48 PM.  I need a return that automatically calculates total time in hours and minutes of the equipment outage.
    Thanks Chris

    Hi,
    In JavaScript you could do something like;
    var DateTimeRegex = /(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d)/;
    var d1 = DateTimeRegex.exec(DateTimeField1.rawValue);
    if (d1 !== null)
        var fromDate = new Date(d1[1], d1[2]-1, d1[3], d1[4], d1[5]);
    var d2 = DateTimeRegex.exec(DateTimeField2.rawValue);
    if (d2 !== null)
        var toDate = new Date(d2[1], d2[2]-1, d2[3], d2[4], d2[5]);
    const millisecondsPerMinute = 1000 * 60;
    const millisecondsPerHour = millisecondsPerMinute * 60;
    const millisecondsPerDay = millisecondsPerHour * 24;
    var interval = toDate.getTime() - fromDate.getTime();
    var days = Math.floor(interval / millisecondsPerDay );
    interval = interval - (days * millisecondsPerDay );
    var hours = Math.floor(interval / millisecondsPerHour );
    interval = interval - (hours * millisecondsPerHour );
    var minutes = Math.floor(interval / millisecondsPerMinute );
    console.println(days + " days, " + hours + " hours, " + minutes + " minutes");
    This assumes that the values in DateTimeField1 and DateTimeField2 are valid, which means the rawValue will be in a format like 2009-03-15T18:15
    Regards
    Bruce

  • Bug in "Announce the time" on half hour

    I have the Clock configure to announce the time on the quarter hour (using Trinoids).
    Most of the announcements are fine however it regularly announces the half hour as "three" rather than "thirty".
    Curiously it happens on almost all, but not on every instance. I've noticed this in 10.5.2 as well which is when I enabled this so not sure about earlier versions.

    Oh and I also use 24 hour clock.

  • Changing Appointment STOP Time From One Hour to Half-Hour.

    On my desktop and on my Centro, appointment "stop" times always default to one hour from the "start" time. I would like to change this so the default is to a half-hour interval. However, I cannot find a setting for this, either on my desktop or on the mobile device.
    I'm changing the "stop" time manually for each entry, which is inconvenient. Is there any way to make it automatic?
    -Paul-
    Post relates to: Centro (Sprint)

    Have you tried this procedure to enter an end time?
    Using the keyboard, enter a starting hour and minute for the event. (For example,
    enter 545 for 5:45.)Select the End Time box, and then select the ending hour and minute for the event. 
    Click on the following link for the support page for your device on the kb.palm.com webpage.
    http://www.palm.com/us/support/centro/centro_sprint/
    There are links on the page to the user guide, troubleshooting, how to's, downloads, etc.
    Post relates to: Palm i705

  • I need PDF fields to calculate time worked and convert to hours and tenths by set formula

    I have been working on a PDF form which has a "time in" field, "time out" field, "total time" and "accumulated time" fields. I have found a couple of forms online which I tried copying the code and it will not work. There is a formula here that they go by, i.e. 0-3 minutes = 0, 4-9 minutes + .1.
    I found code for the conversion but am a beginner at writing code and I am getting errors in the scripting box which I don't understand.
    Does anyone have code written that would work for the Total Time field that will calculate the time between the in and out fields and convert to a set formula? I can get the accumulated field to work.
    I used this:
    document.write(Math.round(0.60) + "1.0");
    document.write(Math.floor(0.57) + "0.90");
    document.write(Math.floor(0.51) + "0.80");
    document.write(Math.floor(0.45) + "0.70");
    document.write(Math.floor(0.39) + "0.60");
    document.write(Math.floor(0.33) + "0.50");
    document.write(Math.floor(0.27) + "0.40");
    document.write(Math.floor(0.21) + "0.30");
    document.write(Math.floor(0.15) + "0.20");
    document.write(Math.floor(0.09) + "0.10");
    document.write(Math.floor(0.03) + "0.00");
    but am missing code to make it work. I am on Acrobat Pro Extended on a Windows 7 platform.
    Thank you in advance, Annette

    I've developed a script that can automatically add these calculation to
    multiple fields, including the total field.
    Have a look here:
    http://try67.blogspot.com/2011/03/acrobat-calculate-time-differences-in.html
    PS -  document.write() is not a valid method in a PDF.

  • How do I create a time field that's export value is 3 hours ahead of the current time?

    I need to create a field on one of our forms that takes the current time from another field and adds 3 hours to it. The JavaScript to pull the current time is:
    var tm = this.getField("Time");
    if(tm.value == '' || tm == ' ') tm.value =
    util.printd("HH:MM tt",new Date());

    Does your posted script work as expected?
    It does not fill-in the field for me.
    Is that code to get the time from a field or set the time for a field?
    Is the field you are trying to update?
    A time string for a computation is very limited or error prone unless it includes the date. There are many locations in the world that still observe Day Light Savings Time or Summer/Winter time and the time either moves forward one hour or falls back one hour at a certain date and time as prescribed by national or local law. So if one want to add 3 hours 1 hour before the time sift for the spring that would be 11:00pm adding 3 hours would result in a time value of 3:00 am the next day and not 2:00 am the next day. The hour between 1:00 am and 2:00 am does not exist for the local time zone.

  • Having problems doing an iCloud backup it keeps showing the estimated time thing but the blue load bar hasn't budged in over a half hour is there a way to correct this

    Having problems doing an iCloud backup it keeps showing the estimated time thing but the blue load bar hasn't budged in over a half hour is there a way to correct this

    You might try a forced shutdown to begin with, hold down the top and home buttons together until the device shuts down, then restart it.
    First check that your device is correctly connected to the wifi/internet (settings > wifi)
    If your back up continually fails, you might try turning off back up on your mobile device (settings > iCloud > storage & backup) and then deleting the backup file from iCloud by swiping the backup file on the mobile device (settings > iCloud > storage & backup > manage…) and then turning back up on again.
    If this doesn't help, try turning off some items for back up in a pattern to try to establish if your problem is being caused by specific data on your device.
    Being able to back up to the cloud can be very useful, especially if you don't have access to a computer or have infrequent access to one, however unless you specifically need to use iCloud for back up, you will find backing up to iTunes significantly more convenient and possibly more reliable.
    More about iCloud v iTunes Back Up

  • Edit Capture Time, Half Hour Time Zone Increment

    Using Lightroom 1.3.1 Windows, I am trying to Edit Capture Time on a batch of photos. Some countries use half hour increments for time zones. How do I shift capture time by +11.5 hours?

    Ummm. I agree? It's completely unintuitive. I think.
    Adobe - please fix it and make it intuitive OK!
    And for the record, this was with LR2.3 on OSX.
    Update: bug filed - http://www.rediguana.co.nz/gav/2009/04/22/bug-lightroom-30-minute-timezone-support/

  • HT203177 I have not backed up my computer using Time Machine since before I updated to Mavericks.  It has been "preparing backup" for a half hour at least and shows no indication of how long this may take.  Is something wrong?

    I have not backed up my computer using Time Machine since before I updated to Mavericks.  It has been "preparing backup" for a half hour at least and shows no indication of how long this may take.  Is something wrong?

    No. TM has to look through your entire drive contents and copy them all. This will take some time.
    Once the first backup is made, then subsequent backup will be much quicker, depending on how much data has changed since the last one.

  • I am trying to restore my phone but everyone I go to do it, it goes to Update which takes 2 and a half hours, and everytime it fails. Ive tried four times now. I'm trying to restore because it says my memory is full, when it is not. I'm so frustrated.

    I am trying to restore my phone, but when i go to do it on iTunes, it Updates to 4.3.3 however everytime the 2 and a half hour update finishes, it FAILS. So the update fails, and the restore fails. Its happened 4 ties.
    Im trying to restore my phone, because it says my memory is full when its not and an online solution says to restore. I cant restore because it wont let me update.
    Im so frustrated, i cant take any pictures, download any music or apps, and its really getting me down. Please can someone help.

    This error generally indicates a hardware failure.  Bring the phone to Apple for evaluation.

  • Is there a way in SSRS 2008 to format datetime to half hour?

    Is there a way to format date time in SSRS 2008 to half hour. I am working on a graph and I am sorting by the hour, but i need
    half hour is there a way I can do this?

    Hi Fozzy767,
    To round time to half hour, we need to use custom function in SQL Server Reporting Service(SSRS). A similiar function can be got from the following thread:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/443a22c6-d5fd-44f6-a379-67f3760537fb/round-time-to-quarter-hour?forum=sqlreportingservices
    To understand how to use custom function, please see:
    http://technet.microsoft.com/en-us/library/ms156028.aspx
    Thanks,
    Jinchun Chen

Maybe you are looking for