Calculate Date/Time Difference in a Calculated Column Omitting Weekends, Holidays and Non-Working Hours

I am looking for a formula to use in a calculated column that calculates the difference between two date/time fields while excluding weekends, holidays and non-working hours
6/1/2010 9:43 AM - 6/7/2010 1:45 PM
Here is the closest that I have gotten; however, this formula gives me a result of 96:
=IF(AND((WEEKDAY([Resolved Date],2))<(WEEKDAY(Created,2)),((WEEKDAY(Created,2))-(WEEKDAY([Resolved Date],2)))>1),(((DATEDIF(Created,[Resolved Date],"D")))-(FLOOR((DATEDIF(Created,[Resolved Date],"D")+1)/7,1))-3),(((DATEDIF(Created,[Resolved Date],"D")))-(FLOOR((DATEDIF(Created,[Resolved
Date],"D")+1)/7,1)*2))*24)
Any and all assistance is greatly appreciated!

I don't know how to exclude holidays but i exclude weekends(Sat&Sun)-
IF(ISERROR(DATEDIF([Start Date],[End Date],”d”)),””,(DATEDIF([Start Date],[End Date],”d”))+1-INT(DATEDIF([Start Date],[End Date],”d”)/7)*2-IF((WEEKDAY([End Date])-WEEKDAY([Start
Date]))<0,2,0)-IF(OR(AND(WEEKDAY([End Date])=7,WEEKDAY([Start Date])=7),AND(WEEKDAY([End Date])=1,WEEKDAY([Start Date])=1)),1,0)-IF(AND(WEEKDAY([Start Date])=1,(WEEKDAY([End Date])-WEEKDAY([Start Date]))>0),1,0)-IF(AND(NOT(WEEKDAY([Start Date])=7),WEEKDAY([End
Date])=7),1,0))
-Thanks
Swapnil

Similar Messages

  • Time Passage Calculation excluding Weekends and Non-work hours

    Good Afternoon Everyone!
    I am currently using the expression below to determine the amount of time that has passed since a Task has been created.
    TIMESTAMPDIFF(SQL_TSI_MINUTE, Activity."Created Date", NOW())
    We have a completion goal for a specific task type of 2 hours (120 minutes), but it should only be calculated minutes between 7 AM and 4 PM and only on week days.
    So, a task created at 3:50 PM on a Friday that is completed at 7:30 AM on the following Monday should only calculate to 40 minutes of time.
    I am at a loss for where to start tackling this problem. If any of you can help I would be very appreciative!

    Hey Paul, thanks for the prompt. I see now that the formula is incomplete.
    As I have just taken the difference in days between the Activity Start Time and End Time, it will consider any weekend. But its incomplete as it considers only 15 hours of a day and not the remaining 9 hours for weekends. For holidays - we do need a field or something to identify it like Activity Type = 'holiday'.
    So the ELSE* part of revised formula would be something like this:
    ... ELSE TIMESTAMPDIFF(SQL_TSI_MIN,activity start time,activity end time) - (60*15*(DAY(Activity End Time) - DAY(Activity Start Time))) - (60*9*(COUNT(DISTINCT CASE WHEN DAYOFWEEEK(Date.Date) IN (6,7) OR ~some field to identify holiday~ = 'something' THEN 1 END)) END
    now imagine there's one activity that started on Friday 7:00 AM and ends on coming Monday at 4:00 PM.
    Actual duration is 18 hours.
    Now,the first term after ELSE will give 81*60 minutes. next term should give 45*60 minutes. third term would be 18*60 min.
    so the entire expression would return 18 hours.
    Even if there's a holiday, then i guess the 'OR' part should capture it.
    I hope this makes sense. Please let me know if it should need any further corrections.

  • Date & time  difference in a single column but multiple rows in a table

    hi folks,
    am using Oracle db 10g by chance is there any other way to do my requirement.
    as I stated in my subject.

    You probably need LAG:
    SQL> -- generating sample data (how hard can it be...)
    SQL> with testdata as (
      2  select 200 bno, 32 temperature, to_date('28.05.2012 09:00:00', 'dd.mm.yyyy hh24:mi:ss') dt from
    dual union
      3  select 200, 36,to_date('28.05.2012 15:00:00', 'dd.mm.yyyy hh24:mi:ss') from dual
      4  )
      5  --
      6  -- actual query:
      7  --
      8  select bno
      9  ,      temperature
    10  ,      dt
    11  ,      numtodsinterval(dt-lag(dt) over (partition by bno order by dt), 'day') difference_int
    12  ,      substr((numtodsinterval(dt-lag(dt) over (partition by bno order by dt), 'day')), 12, 8)
    difference_dt
    13  from   testdata;
           BNO TEMPERATURE DT                  DIFFERENCE_INT                 DIFFEREN
           200          32 28-05-2012 09:00:00
           200          36 28-05-2012 15:00:00 +000000000 06:00:00.000000000  06:00:00
    2 rows selected.But, as Paulie already said: still insufficient input. We know nothing about your datatypes. I assumed you're using a DATE.

  • How to calculate the time difference in answers

    Hi,
    I need to calculate the time difference in BI answers and I dont have the access to the repository. I have the data in the following format
    10/12/2005 7:24:19 PM 10/12/2005 7:32:04 PM
    10/12/2005 7:50:47 PM 10/12/2005 8:52:36 PM
    10/12/2005 7:54:23 PM 11/4/2005 10:47:32 PM
    10/12/2005 9:05:51 PM 10/12/2005 9:08:58 PM
    10/12/2005 9:07:42 PM 10/12/2005 9:14:47 PM
    10/12/2005 9:09:02 PM 10/12/2005 9:10:57 PM
    I need to get the elapased hours between these two columns. Please help me
    Thanks

    you can use beans or create a case when statement like:
    case
    when TimeStampDiff(SQL_TSI_Min, table.column1, table.column2 ) <= 60 then 1 else
    when TimeStampDiff(SQL_TSI_Min, table.column1, table.column2 ) > 60 and TimeStampDiff(SQL_TSI_Min, table.column1, table.column2 ) <= 90 then 1.5 else
    when TimeStampDiff(SQL_TSI_Min, table.column1, table.column2 ) > 90 and TimeStampDiff(SQL_TSI_Min, table.column1, table.column2 ) <= 150 then 2.5 else
    end

  • How to measure time difference between zero crossing of a sine wave and rise time of a pulse on a same graph?

    I have a 50Hz sine wave and a pulse signal on a same graph. The phase difference between two is between 0-90 degrees.
    Now I need to calculate the time difference between (when the sine wave crosses zero volts) and (when the pulse rises). The frequency will stay approximately same for both signals.
    The application is for a three phase generator. In simple words, when the time difference between the zero-crossing of sine wave and the pulse rises increases, that means that the load on the generator has increases.
    I am a beginner user of LabView (version 9, 2009), maybe it is a very simple problem but I've been pulling my hair out for the last few days and coudln't figure anything out. Any help would be greatly appreciated. I am using DAQ USB-6008 to measure these voltages and pulse from the generator and a sensor
    I have attached a jpg (a graph that i just made with excel to explain). The time 't' is what I am trying to measure
    Cheers
    Awais 
    Message Edited by awais.h on 03-30-2010 11:20 PM
    Message Edited by awais.h on 03-30-2010 11:21 PM
    Solved!
    Go to Solution.

    Hi
    Thanks for the code but I'm afraid it won't work. Like you said the probability of choosing a value that is on both graphs may not happen. This is something that I would like the code to do automatically.
    But I did use the previous code posted and made some modifications to it and it seems to work perfectly. Now the next thing is to be able to get just that one value that tells you the first time difference.
    Here is what I get using that code.
    As you can see from the t Values. I only need the one that is highlighted. If there is a way to filter out the rest it would be great.
    I was thinking of a while loop and as soon as the value is higher than 3E-5 it would store the number and stop the loop, but I'm not too familiar with arrays in labview.
    Here is the the code modified.
    As you can see, it wasn't that big of a modification and it still is your code.
    I will keep trying.
    Thanks for the help
    Attachments:
    FinalShockSpeed.vi ‏55 KB

  • Since last week my date & time have not worked on my 5c. The date & time are constantly wrong. I've shut down, doesn't work. Set it automatically, doesn't work. I don't get texts or calls when it's sleeping. Any suggestions?

    Since last week my date & time have not worked on my 5c. The date & time are constantly wrong. I've shut down, doesn't work. Set it automatically, doesn't work. I don't get texts or calls when it's sleeping. Any suggestions?

    try a reset.
    Hold the home & power buttons down simultaneously until you see the Apple logo appear.
    Note: no data will be lost.

  • I am having multiple issues with syncing my iphone calendar and outlook There are often 1 hour time differences in the entries on the 2 devices and sometimes events that have been amended are not updated on iphone I mostly enter items on my laptop

    I am having multiple issues with syncing my iphone calendar and outlook calendar on my laptop
    I mostly enter the original items on my laptop
    There are often 1 hour time differences in the entries on the 2 devices and sometimes events that have been amended are not updated on iphone

    This sounds like an error in Time Zone support. The time zone needs to be the same in Outlook as well as the phone.

  • Whenever I go to iTunes with my iPod 5th generation 32 gb iPod Touch, running iOS 8.0.2, It tells me that the "Other" category is using up 14.59 gb of data. I have no clue why it says this and I have searched the internet for fixes and none worked.

    Whenever I go to iTunes with my iPod 5th generation 32 gb iPod Touch, running iOS 8.0.2, It tells me that the "Other" category is using up 14.59 gb of data. I have no clue why it says this and I have searched the internet for fixes and none worked. I have tried on a windows and a mac and noticed no change. I have tried restoring to a backup but that didn't help. I haven't had time to do a full restore but I will try if the problem persists.

    An "other" larger than about 1 1/2 GB indicates corrupted files.
    What is the Other on my iPhone and How to Remove It
    What is "Other" and What Can I Do About It?
    Next, usually restoring from backup eliminated the corrupted files. However, sometimes restoring to factory settings/new iPod is required.
    To restore from backup see:
    iOS: How to back up
    To restore to factory settings/new iPod see:
    iTunes: Restoring iOS software

  • I installed the LR CC, signed in and out, restarted computer, UN-installed CC and installed again, signed in and out several more times. Nothing!!! I have Lr5 and it works fine, Lr6/CC will not open. I'm lost!!  It is currently uninstalled.

    I installed the LR CC, signed in and out, restarted computer, UN-installed CC and installed again, signed in and out several more times. Nothing!!! I have Lr5 and it works fine, Lr6/CC will not open. I'm lost!!

    CC applications close immediately after launch
    if that fails to help, contact adobe support by clicking here and, when available, click 'still need help', https://helpx.adobe.com/contact.html

  • How to calculate the Time difference between 2 dates

    HI All,
    I am using HR_hk_diff_btw_2_dates to calculate the employee service dates.
    For that i  am inputing his hire date and Term dates and Output format as '05' i am getting output perfectly....
    But problem is  whe i am inputting the employee hire date is Dec 1 2007 and Term date is
    March 31 2009 It is coming as 1 year 3 months  31 days instead of 1 year 4 months directly .......How could we make it make last date also working day and get the O/p as 1 year 4 months ?Please Advice..
    Regard
    sas

    1. FM for difference betwwen two times:SCOV_TIME_DIFF
    Import parameters               Value
    IM_DATE1                        2008-01-01
    IM_DATE2                        2008-01-01
    IM_TIME1                        10:00:00
    IM_TIME2                        11:30:00
    Export parameters               Value
    EX_DAYS                         0
    EX_TIME                         01:30:00
    2. SD_CALC_DURATION_FROM_DATETIME : Finds the difference between two date/time and report the difference in hours
    L_MC_TIME_DIFFERENCE : Finds the time difference between two date/time

  • Date/Time difference based on working days

    Hi Guru's,
           I am having a problem getting the difference between two timestamps. A normal difference between 2 timestamps is possible however i would like to calculate the hour difference between 2 timestamps excluding public holidays, weekends and also after office hours. Is there a series of FM or a logic to extract this kind of info. Hope you guys can shed some light into the matter.
    Thanks in advance.
    Anand

    Hi,
    Use FM DATE_COMPUTE_DAY. DATE in MM/DD/YYYY format.
    This FM returns the date in form of weekday number ie the date which you give is tuesday then it will return 2.
    Give call log date and call handled date.
    eg A call is logded on tuesday 3.00 pm and handled on Thursday 10.a.m.
    First check the days difference from the return of this FM.
    IF the call handled date return - call loged date return is positive means no sat sun , if negative means sat and sun.
    then from call logged date time start counting the office hours till call handled time.
    Office hours can be easily calculated using 24 hours clock.
    For public holidays have to check whether between the twodates any public holiday if is there then subtract that much office hours.
    Hope this helps.
    Thanks,
    Niketa

  • How to calculate the time duration on a datetime column?

    Hi guys,
    I've done some search on this forum and everywhere else but I can't seem to get this right, at the beggining it sounded like something very simple to accomplish, for the instance with Excel but I'm struggling to get it to work with Crystal Reports on Microsoft Visual Studio 2008.
    I have a datetime column (SQL Server 2000) that I wanted to calculate the the time duration on the report group footer, unfortunatelly the built-in SUM function cannot be applied and I've tried several formulas that I've found on the internet without any luck. I'm using a datetime column to store only the time because I'm stuck with SQL Server 2000 which doesn't have a time data type.
    Would you guys know how to do it by any chance?
    Some sample code I've tried: http://www.minisolve.com/TipsAddUpTime.htm
    Thanks a lot,
    Paul
    Edited by: Paul Doe on Dec 12, 2009 5:41 PM
    Some sample data:
    EMPLOYEE     WORK HOURS
    =========     =================
    JOHN DOE      1900-01-01 01:00:05
    JOHN DOE      1900-01-01 00:20:00
    JOHN DOE      1900-01-01 01:30:15
    =========     =================
    HOURS WORKED: 02:50:20
    Edited by: Paul Doe on Dec 12, 2009 5:42 PM
    Edited by: Paul Doe on Dec 12, 2009 5:45 PM

    Guess what, by further testing the code on the website mentioned above I got it working.
    Pus, I needed to change the grouping on the code, so I had to come up with a way to update the formulas based on the groupping field.
    Considering "call_date" is the field that you are groupping by on the designer use the following code to update the formula:
    CrystalReportObj = new ReportDocument();
    CrystalReportObj.Load("C:\\reportfile.rpt");
    FieldDefinition FieldDef;
    //Get formula
    FormulaFieldDefinition FormulaDef1;
    FormulaDef1 = CrystalReportObj.DataDefinition.FormulaFields["SubHours"];
    //Get formula
    FormulaFieldDefinition FormulaDef2;
    FormulaDef2 = CrystalReportObj.DataDefinition.FormulaFields["subMinSec"];
    //Update the formula to work with the new grouping field,
    //this must be called first else will throw an exception
    FormulaDef1.Text = FormulaDef1.Text.Replace("call_date", "call_extension");
    FormulaDef2.Text = FormulaDef2.Text.Replace("call_date", "call_extension");
    //Get the new field we are grouping by
    FieldDef = CrystalReportObj.Database.Tables[0].Fields["call_extension"];
    //Replace current grouping field with the new one,
    //considering there only one group in the report, index 0
    CrystalReportObj.DataDefinition.Groups[0].ConditionField = FieldDef;
    Have fun.
    Edited by: Paul Doe on Dec 12, 2009 8:43 PM
    Edited by: Paul Doe on Dec 12, 2009 8:53 PM

  • Function Module for Date/ Time difference in Working Days

    Hi all,
    Are there any function modules which will calculate the difference between a date AND time, but in working days?
    I can use the FIMA_DAYS_BETWEEN_TWO_DATES_2 FM for the dates, but I need to include times in this as well.
    This is for situations where the 'starting date' is a non-working day, and the 'end date' is a working day.  In this situation I need to take all the hours and minutes into account, which happened on the working day.  To give an example -
    Start date:  04.07.2010 (Sunday - Non working day)
    Start time:  21:12:36
    End date:  05.07.2010 (Monday - Working day)
    End time:  04:47:24
    I realise there is a Time option in this function module, but when I test it, it doesn't seem to be returning the desired results (returns 0 for days and time).  I am using '5' as the I_STGMETH and 'GB' as the I_SKALID. 
    I need a calcuation which will return the time, post midnight on the working day - in this example, 4 hours, 47 minutes (seconds are optional!).
    Can anyone help? - can I still use FIMA_DAYS_BETWEEN_TWO_DATES_2 but with different parameters?
    Thanks
    Mischa
    Edited by: Mischa Gulseven on Jul 20, 2010 10:40 AM

    Hi,
    Thanks but this FM does not seem to account for working days.
    For example, if I use:
    DATE1                           04.07.2010  (non working day)
    TIME1                           04:00:00
    DATE2                           05.07.2010   (working day)
    TIME2                           21:00:00
    It will give the following results -
    DATEDIFF                                                      1
    TIMEDIFF                                                     17
    EARLIEST                        1
    I don't want to account for the non-working day so the result I actually want would be to calculate from midnight on 05.07 to 21:00 on 05.07 which should be 21 hours.
    I suspect I probably need to include the STGMETH and the factory calendar somewhere in the FM?
    Does such a FM exist, or could anyone help me with some ABAP for this?
    thanks
    Mischa

  • Help with calculated column formula- combine strings and convert to date

    In my list (SharePoint Server 2013) I have:
    'Invoiced Month' column, type of choice (strings with names of months- January, February, March..., December)
    'Year' column, single line of text (e.g. 2012, 2013, 2014)
    1. I need to create a calculated column which will return combined value of the columns above, but in DATE format e.g. 'Sep-2013' or '01-Sep-2013'.
    I then use that newly created calculated column to do this: http://iwillsharemypoint.blogspot.in/2012/03/sharepoint-list-view-of-current-month.html
    I am rubbish with formulas, can I have some help with my problem please?

    Hi,
    Use the formula, I have tested by creating Months column with choice, Year column as numeric and Calculated column as DateTime returned.
    =DATE(Year,IF([Months]="January", 1,IF([Months]="February",2,IF([Months]="March",3,IF([Months]="April",4,IF([Months]="May",5,IF([Months]="June",6,IF([Months]="July",7,IF([Months]="August",8,IF([Months]="September",9,IF([Months]="October",10,IF([Months]="November",11,12))))))))))),1)
    Before applying the formula few things need to be noted.
    DATE(YEAR, MONTH,DAY) will accepts three parameters all should be type numeric(integer).
    Create the Year column of type numeric
    Create the calculated column of type "DateTime" to return as date
    Please mark it answered, if your problem resolved or helpful.

  • Calculate Date/Time based on TimeZone

    Hi guys,
    what i want to do is the following:
    given a database table tzdata composed of time zone names and tz offset
    like this :
    tzName tzOffset summer time used
    Afghanistan ,+4.5, no
    Albania ,+1, yes
    Algeria, +1, yes
    American Samoa,-11, no
    i want to be able to display the corresponding Date / Time of each country based on the time zone offset .
    I'm using a SimpleDateFormat , and want to know how to calulate time for each entry in table above.
    thanks for helping !

    given a database table tzdata composed of time zone names and tz offset
    i want to be able to display the corresponding Date / Time of each country
    based on the time zone offset .
    in the offsets i posted above i found things like +10.5 ,-1.2 ect..
    how to convert those into the correct format so i can feed it to SimpleTimeZone() construtor ?Why would you want to?
    I am just pointing out here that java already has all those timezones and offsets configured into it. As well as if/when DST applies.
    String[] zones = TimeZone.getAvailableIDs();
            for (int i=0; i<zones.length; i++){
              System.out.println("Zone " + i + " = " + zones[i] + " offset = " + TimeZone.getTimeZone(zones).getRawOffset());
    In other words this database table is reinventing the wheel.
    You just need to tell Java which Timezone you want (according to the standard names for timezones begin Region/City) and it will work out the correct offset.
    eg
    for Afghanistan: new TimeZone("Asia/Kabul");
    Albania: new TimeZone("Europe/Tirane");
    Cheers,
    evnafets

Maybe you are looking for

  • Music plays in iTunes, but NONE of the MP3 files are visible in Explorer

    This one is a bit of a mystery. When I open up any of the folders in my iTunes Music folder, they appear to be empty. No MP3 files are listed at all. Yet, iTunes can still play the music. Here are the details: 1. I keep my iTunes media content on an

  • HTML Client: How to get the content/value of a custom control?

    I made two Custom Controls named, "CustomControl_1" and "CustomControl_2".  In the render function of "CustomControl_1", how to access the value of "CustomControl_2"? For example, myapp.BrowseOrders.CustomControl_2_render = function (element, content

  • How to use SQL*LOADER to read data in |SMITH|ALFRED| format

    the data I need to upload to table using SQL*LOADER is in format as below: |AD |Argentina  | |CN |China       | |US |America            | |GB |England        |so how should I write my control file to read the data into two columns table? I googled an

  • Writing files in UTF-8 format

    Hi, Our system is unicode enable and I want to write a file in UTF-8 format. I'tried  the following syntax. OPEN DATASET l_filename FOR OUTPUT IN TEXT MODE ENCODING UTF-8. and OPEN DATASET l_filename FOR OUTPUT IN TEXT MODE ENCODING default But when

  • HELP ME PLZZ !  my macbook os 10.4 to 10.6

    i upgrade my macbook os 10.4 to 10.6 but it ask about the time machine but when i want to reinstall the ox 10.4 it wont starup it just a gray screen with the question file what will i do now