Difference between 2 timestamp,not considering the weekends (SATURDAY,SUN)

I use an Oracle XE and I have a table which has the following Timestamp columns
A_Date Timestamp
R_Date Timestamp
Now in this query i need to be able to exclude the SAT/SUN and show the difference between these 2 timestamp dates.
Could any one help on this?
I use this query to find out the difference between the 2 dates (R_DATE - A_DATE),showing the DAYS:HOURS:MIN:SECS
TRUNC (TO_NUMBER (SUBSTR ((R_DATE - A_DATE),
1,
INSTR (R_DATE - A_DATE, ' ')
|| ':'
|| SUBSTR ((R_DATE - A_DATE),
INSTR ((R_DATE - A_DATE), ' ') + 1,
2
|| ':'
|| SUBSTR ((R_DATE - A_DATE),
INSTR ((R_DATE - A_DATE), ' ') + 4,
2
|| ':'
|| SUBSTR ((R_DATE - A_DATE),
INSTR ((R_DATE - A_DATE), ' ') + 7,
2
) "TTR"
Example : A_DATE := '11-Dec-2009 19:33:30 PM' ---> Friday
R_DATE := '14-Dec-2009 07:32:38 AM' ---> Monday
should not consider the SAT/SUN that comes between them.
Thanks
GAG

SQL> create table t as (
  2  select to_timestamp('11-dec-2009 07:33:30 PM') rdate
  3  ,      to_timestamp('14-dec-2009 07:32:38 AM') adate
  4  from   dual
  5  );
Table created.
SQL> select rdate
  2  ,      adate
  3         /* do some final formatting */
  4  ,      to_number(substr(diff_incl_weekend, 1, instr( diff_incl_weekend, chr(32))))
  5         ||':'||
  6         substr(diff_incl_weekend, instr( diff_incl_weekend, chr(32))+1, 8) diff_incl_weekend
  7  ,      to_number(substr(diff_excl_weekend, 1, instr( diff_excl_weekend, chr(32))))
  8         ||':'||
  9         substr(diff_incl_weekend, instr( diff_excl_weekend, chr(32))+1, 8) diff_excl_weekend    
10  from ( /* substract intervals */
11         select to_char(rdate, 'dd-mon-yyyy hh:mi:ss AM') rdate
12         ,      to_char(adate, 'dd-mon-yyyy hh:mi:ss AM') adate
13         ,      trim('+'
14                from
15                numtodsinterval((to_date(to_char(adate, 'dd-mon-yyyy hh:mi:ss AM'), 'dd-mon-yyyy hh:mi:ss AM')
16                                 -
17                                 to_date(to_char(rdate, 'dd-mon-yyyy hh:mi:ss AM'), 'dd-mon-yyyy hh:mi:ss AM')
18                                )
19                               , 'day')
20                    ) diff_incl_weekend
21         ,      trim('+'
22                from            
23                numtodsinterval((to_date(to_char(adate, 'dd-mon-yyyy hh:mi:ss AM'), 'dd-mon-yyyy hh:mi:ss AM')
24                                 -
25                                 to_date(to_char(rdate, 'dd-mon-yyyy hh:mi:ss AM'), 'dd-mon-yyyy hh:mi:ss AM')
26                                 -
27                                 nof_satsuns.total
28                                )
29                               , 'day')
30                    ) diff_excl_weekend
31         from   t
32         ,      /* calculate nof sats and suns*/
33              ( select count(dy) total
34                from ( select to_char(rdate+level-1, 'dy') dy
35                       from   t
36                       where  to_char(rdate+level-1, 'dy', 'nls_date_language=american') in ('sat','sun')
37                       connect by level <= trunc(to_date(to_char(adate, 'dd-mon-yyyy hh:mi:ss AM'), 'dd-mon-yyyy hh:mi:ss AM'))
38                                           -
39                                           trunc(to_date(to_char(rdate, 'dd-mon-yyyy hh:mi:ss AM'), 'dd-mon-yyyy hh:mi:ss AM'))+1
40                     )    
41              ) nof_satsuns
42      );
RDATE                   ADATE                   DIFF_INCL_WEEKEND                                 DIFF_EXCL_WEEKEND
11-dec-2009 07:33:30 PM 14-dec-2009 07:32:38 AM 2:11:59:08                                        0:11:59:08

Similar Messages

  • X131e back cover FRUs - what's the difference between DEC or not?

    I'd like to buy a replacement LCD cover kit for an x131e but the FRU part lists the following: 04W3863 LCD Cover Kit Black04W3864 LCD Cover Kit Red04W6853 LCD Cover Kit Yellow04Y1781 LCD Cover Kit DEC Red04Y1782 LCD Cover Kit DEC White04Y1783 LCD Cover Kit DEC BlackWhat's the difference between DEC or not DEC? I can't find any visual differences in the few websites that carry them.

    The difference is TVSU stopped working and TVUR+TI still works.
    T500: Vista 32, 2.8GHz, 4GB RAM, 15.4" 1680x1050, 500GB 7200rpm, ATI Radeon HD3650 + Intel 4500MHD. T42: XP, 1.7GHz, 2GB RAM, 14.1" 1024x768, 250GB PATA, ATI Radeon 7500.

  • What is the difference between Never and Not supported

    What is the difference between Never and Not supported?
    Also I want to know what are all the transaction attibutes are supported by MDB and why?

    Never- If the bean is called in an existing trasaction an exception is thrown.
    NotSupported - Methods always execute outside the transaction context. If a transaction is started when this method is called, this method is executed outside the transaction. The initial transaction is continued after the method exits.

  • I did re-set my password and when I click on Install for Mavericks, I still get a box for "administrator password" and it still won't accept my new password. Is there a difference between my Apple ID and the administrator password they're asking for?

    I downloaded Mavericks and it won't install. I did re-set my password and when I click on Install for Mavericks, I still get a box for "administrator password" and it still won't accept my new password. Is there a difference between my Apple ID and the administrator password they're asking for? I never had an administrator password-- I just hit enter and have never had a problem before with previous installations. I'm on an iMac, from 2007, running Mt. Lion (version 10.8.5). I've been looking for other's posts who may be having the same problem, but haven't found any. Can anyone help?

    Ugh. The 'no password, no work' thing is a recent Apple development. I ran into it on my system and ended up having to do a clean install on a partition I fully erased.
    I suppose, if you have the ability to, go online and look up how to burn a bootable DVD image. Download the 10.8.4 image then use the Disk Utility to make a boot image of it. You'll need a dual-layer DVD or a USB drive (or memory stick at least 8GB) If you've got an optical drive, burn the disk, if you've a USB device, use that.
    Then get a pocket drive and copy your important files off the system or let Time Machine do a full backup.
    When the backup is done, insert the disk and hold down the C key until the machine boots off of the DVD. At the point you get to the start window, go to the menu and choose the Disk Utility.
    In the Disk Utility, reformat the drive. You go to the actual DRIVE (not the Macintosh HD, but the root above it that is the actual hard drive device)
    I always do this and *partition* it into several volumes, the benefit being, you can store all of your music, documents and importans stuff on that secondary storage volume you make - it will have it's own index and then the first volume is where you put the OS and it will have it's own index as well. That way, if the OS throws a wobbler and you need to reinstall, you don't lose your data.
    Depending on the size of your hard drive, it is good to give your OS partition at least 60GB and optimally 100GB, and the rest for storage.
    Name your volumes, use the little box sliders to manually size them or put that number in the size window, select for the format, Mac OS Extended (Journaled) and hit Apply and then the Disk Utility will quickly create your new partitions.
    Once finished, quit the Utility and it will return you to the OS installer. Select the volume you want to install to and it should start up and install.
    Once the installation is done, you'll get the new machine startup then you MUST put in a password for the computer. Once you're in, and to the desktop, don't bother with any Mountain Lion updates, go right to the App Store and get the Mavericks update and let it install the app to your Applicaitons folder, then do that install.
    On a side note, there MAY be a way to make a disk image from the Mavericks application and avoid the entire Mountain Lion step.. I honestly do not know, but a bit of hitting the search engines may find out if there is. I think that if you looked for "make Mavericks boot disk or boot image' you may find something.
    Good luck!

  • Difference between two timestamp.

    Hi,
    I want to find difference between two timestamp in minutes.
    Actually i want to retrieve difference between current timestamp and the timestamp taken from the table
    select log_time from serv_info where server_id = 1;
    Can anyone tell me the query to find difference between two timestamps in minutes.
    -haifriends

    SQL> WITH serv_in AS
         (SELECT SYSTIMESTAMP - 1 / 4 log_time,
                 SYSTIMESTAMP now
            FROM DUAL)
    SELECT log_time,
           now,
             24 * 60 * EXTRACT (DAY FROM (now - log_time))
           + 60 * EXTRACT (HOUR FROM (now - log_time))
           + EXTRACT (MINUTE FROM (now - log_time))
           + 1 / 60 * EXTRACT (SECOND FROM (now - log_time)) diff_in_minutes
      FROM serv_in
    LOG_TIME  NOW                                 DIFF_IN_MINUTES
    01-MRZ-07 01-MAR-07 03.47.42.107462 PM +01:00      360,001791

  • Difference between -1 and null in the targettype filed

    Hi
    Could anyone advise what is the difference between -1 and null in the targettype filed in marketing documents?
    For example, in Sales Quotation - Rows (QUT1) table, I found for some open sales quotations, the field is null however the DB help file suggest the default value is -1 so I suppose it should be -1 for open documents.
    Many thanks for your advisory.

    Hi, Qian!
    I investigated that "-1" value appears in targettype field in Sales Quotation Rows (QUT1 table) when you Dublicate a Sales Quotation document (Ctrl + D). And NULL value appears when you create a new document without dublicating.
    In case you want to equal these 2 "empty"-values using T-SQL, you can use ISNULL(targettype, -1) function - this will give you -1 for both the "empty"-values
    HTH!
    Message was edited by: Aleksey Kuznetsov

  • FI-AP Tax Code not considering the excise duty while calcuating the VAT

    Sub: A/P Tax Code not considering the excise duty while calcuating the VAT
    Hi Frnds.
    I have a typical problem.
    Till now we are using a "W6" as a tax code, where Excise-10%, Ed Cess-2%, SEd Cess-1% and VAT-4%.
    But as the Govt. rules changed I have created a new tax code "W8" by copying the W6 and modified the VAT to 5% by changing the condition record JVRD.
    The new tax code is not calculating VAT part correctly. It is taxing into consideration Invoice Base value, Ed Cess & SEd Cess (Omiting the Excise Duty).
    I have checked my Tax Procedure, there everything is fine. Even my old tax code "W6" is working correctly.
    Let me know where the error lies.
    Here is the scenario
    00. Tax code                       -   W6   -   W8   - Current Staus of W8
    01. Invoice Base               - 355181 - 351798 - 353324 (by SAP Document Simulation View)
    02. Excise @ 10% on 01.        -  35518 -  35180 -  35332
    03. Ed Cess @ 2% on 01.        -    710 -    704 -    707
    04. SEd Cess @ 1% on 01.       -    355 -    352 -    353
    05. VAT @ 4% on (010203+04)  -  15671 -   0     -  0
    05.    VAT @ 5% on (010203+04)  -    0    -  19401 -  0
    05.     VAT @ 5% on (010304)     -   0     -    0    -  17719
    INVOICE TOTAL VALUE            - 407435 - 407435 - 407435
    Pls. let me know how to come over the issue.
    By the way I am using the above tax code at FB60 transaction code.
    Regards
    Krishna
    Edited by: Gopi Krishna Gutti on Oct 17, 2011 10:18 AM

    Hi Vivek
    Acutually we planned to implement SAP - FI & MM Modules only, and all the configuration is done in the system, but at the final stage our management is not satisfied with MM area, so finally we have gone live with only FI Moudle.
    By the way thankyou for the reply. I have maintained 100% in JMX1 for the new tax code and it is working fine.
    I will give you full points.
    Once again thanks a lot.
    Regards
    Krishna

  • I want to create an app.  Can you tell me the difference between iOS developer program and the mac developer program?

    I want to create an app.  Can you tell me the difference between iOS developer program and the mac developer program?
    Is the difference the device you're creating your app on, or for?

    iOS Developer Program is only for those who wish to develop iDevice apps. Mac program is for those only developing Mac applications. If you wish to do both, then you need to enroll in both programs.

  • Do not consider the stock onhand during SNP.

    Hi APO specialists.
    I'd like to run SNP plan that do not consider the stock onhand.
    Material A is purchase item. and the forecast of material A has 400 qty.
    and stock onhand is 200 qty.
    But I want to make the purchase request as 400 qty.
    How to ?
    Anyone who has the solution can reply this question.
    Thank you all.

    Hi,
    Try following in separate planning book by copying standard planning book.
    In a macro for stock balance change the step for calculation of stock on hand projected. In this step remove the function of INITIAL_STOCK.
    Regards,
    Vaibhav
    Edited by: Vaibhav Birwadkar on May 26, 2008 7:20 AM

  • The system is not considering the free stock in planning strategy grp - 25

    Dear Frndz,
    The system is not considering the free stock of child items available in the system.For the parent item, I have maintained a planning srategy of 25 (Make to order variant config).My client would like the system to consider the free stock available for child items.pls help me...
    Regards,
    Srini

    Dear,
    Strategy 25 will not consider the existing stock.
    What you enter in MRP4 view ind/collective rquirement is applicable only for dependent requirement.
    Also refer this thread?
    Re: Strategy group 20
    Run MRP in MD50 and then MD02 with palnning mode 3 deleted and recreated and check your result.
    Regards,
    R.Brahmankar

  • Difference between SAP/APO/DP and the SAP/CRM solution for forecasting

    Hi,
    Can you please help me identifying the main differences between SAP/APO/DP and the SAP/CRM solution for forecasting? Advantages and disadvantages?
    Thanks a lot

    Hi LCD777,
    Forecasting at DP & CRM are altogether at different entities.  CRM involves webbased data transfer mechanism tool whereas DP is database/livecache driven tool.
    In CRM, you dont get optimised solution of forecasting out of it whereas in DP you can get as much as
    optimised solution & flexibility as per your requirements.
    DP is majorly a forecasting tool where in huge statistical method functionalities are embedded in
    whereas CRM is majorly a transactional tool wherein it involves gathering of forecast data and executing it.
    Typically, CRM will be integrated with DP containing GATP environment & ECC so that DP will plan for forecast data, ECC system drives sales order data & GATP calls for availability check and finally
    the forecast execution& transactions will be controlled by CRM
    Regards
    R. Senthil Mareeswaran.

  • The differences between an applications created in the classic mode vs. EPM

    Hi,
    the differences between an applications created in the classic mode vs. EPMA?
    Thanks
    SYED
    Edited by: SYED on Jun 15, 2009 5:38 AM

    Hi Carla
    Are these ledgers A and B your FI ledgers - Leading & Non Leading?
    KO8G has no specification to restrict posting to any FI ledger... By default, the postings made in Leadin ledger go to Non Leading as well...
    If you are settling to a GL in KO8G which is restricted only to Non Leading Ledger, then that might be the cause. however, you can restrict a GL to ledger only on a system which is on EhP4
    Regards
    Ajay M

  • Difference between service order/notification to the maintenace order/notif

    Hello friends,
    please explain the Difference between service order/notification to the maintenace order/notif and also to the Sales order.
    i have a idea on the above topics. iwnt to have a detailed explanation of the above topics.
    I know that service order/notification usually for external services.and maintenance O/notification for internal services .
    for every post with descent information, points willl be rewarded

    Dear raj kumar,
    1. Service order and Notification: These are used for Customer Services, i.e., these are used for  processing the customer complaints regarding the equipments technical problems installed at customer locations.
    In this scenario, we sell equipments to customer and also offers the services for that equipments on chargeable basis or free of cost as per sales terms and conditions.
    2. Maintenance order and Notification: These are used for Plants, i.e., for processing the complaints of the equipments which are installed within the plant.
    In this scenario, we buy the equipments from the vendors and carry out the maintenance ourselves.
    Hope this will be helpful
    Regards,
    Praveen.

  • Difference between SAP Software Kernel and the files in Kernel Directory

    27.     What is the difference between SAP Software Kernel and the files in Kernel Directory

    well... the OS kernel is for the... "OS" and the SAP Kernel is for.... "SAP"
    A kernel is the core of any application, basically is a set of programs and parameters that tell the system how to behave.
    Regards
    Juan

  • What is the difference between Macs Voice Over and the text to talk feature

    what is the difference between Macs Voice Over and the text to talk feature

    Voice Over doesn't need someone to type in the text first. Voice Over works with specific screen displayed information so that a blind person can know where his/her cursor is or what is being displayed. Although it is an application of text to talk it's more than the text to talk feature.

Maybe you are looking for

  • Dynamic type variable creation

    I want to create a variable with a pre-defined TYPE, but the latter will only be known at runtime. For instance: Consider that I my DEFINITIONS1 include file is: TYPES: BEGIN OF type1,                 field1 TYPE i,                 field2 TYPE i,    

  • SRM 7.02 DUMP with user ID WF-BATCH

    Dear Experts, recently we are facing issue with dumps in our system with user ID WF-BATCH and the dump is due to TIME_OUT. The description in ST22 is: The program "/SAPSRM/CB_WF_PROCESS=========CP" has exceeded the maximum permitted run time without

  • One of my pages does not publish

    I have 4 different iweb sites directed to 4 different URL addresses (example:www.xx.com). 3 of them publish ok and I can see them at their respective URL, but the fourth site seems to publish ok, the whole progress pie chart finishes its cycle and th

  • Repetitive crash, macbook with Retina, 2012

    I am having a repetitive crash which I "think" may be associated with a specific website. The website is just a local news site "expressandstar.co.uk". Of course, I cannot be positive that the website is the main culprit or it is triggering another i

  • [SOLVED] Opus codec support

    "Release notes for GStreamer Bad Plug-ins 0.10.23 "The Game Has Changed" - opus: new Opus audio codec elements: opusdec, opusenc, opusparsertpopusdepay, rtpopusay In arch I have: gstreamer0.10-bad-plugins 0.10.23-2 is not support opus. New version su