Number of Days with difference in 2 columns

Dear all,
Is this possible to display Number of Days with difference in 2 columns.
Regards,

Or use simply the ABS() function
select abs(  date1 - date2 ) from dual ;Francois

Similar Messages

  • Calculating number of days without weekend and holidays

    Hallo all,
    can someone help me with a formular to calculate the number of days with Crystal Reports 2008 between two dates without weekends and holidays
    eg.
    date one = 03/24/2010
    date two = 03/29/2010
    Result should be 4 days as 03/27 and 03/28 will be a weekend.
    Plus how to exclude holidays ?
    Thank you very much
    Gerald

    As Doug mentioned, Holidays are very location specific, and are you talking about "corporate holidays" where the company is closed, or "public holidays" where banks (<g>) are closed?
    I'd suggest setting up a calendar table (if you don't have one already), one record per date.  You could make it work-days only, days-off only, or all dates with a flag to indicate if it is a work date.  You could then use that to count the number of work days.  By using a table, you wouldn't have to change any code to (a) extend your calendar to the following year, or (b) change holiday dates if the holidays change.  (I'm thinking corporate holidays, where the company might be closed Friday 12/24/10 in observation of Christmas, but would usually only close on the 25th.)
    HTH,
    Carl

  • Number of days difference

    Here is my query, I am trying to find out number of days difference from Jan 1st that year to particular date of that year. Please let me know what wrong with that query?
    SELECT TO_CHAR(30/06/2009,'DD/MM/YYYY') - (TO_CHAR('01-01-'||TO_CHAR(30/06/2009, 'YYYY'), 'DD/MM/YYYY')) + 1 from dual;Thanks for the help.

    Hi,
    Instead of playing guessing game with what error you are getting, it would have been much helpful if you state the error
    Anyways, you cannot substract two char datatype, it should be a date datatype to substract.
    select to_date(30/06/2009,'DD/MM/YYYY') - trunc(to_date(30/06/2009,'DD/MM/YYYY'),'YYYY')+ 1 from dualPS: Code is not tested. If found any error please post the error message too.
    Regards
    Anurag

  • They sent me a serial number for a windows version of PS Elements when I ordered a mac version.  The serial number doesn't work, not surprisingly, but they don' t seem to care.  I have tried the chat line and have waited for almost a day with no response.

    They sent me a serial number for a windows version of PS Elements when I ordered a mac version.  The serial number doesn't work, not surprisingly, but they don' t seem to care.  I have tried the chat line and have waited for almost a day with no response.  What should I do?

    Look here
    Order product | Platform, language swap

  • How do you work out the number of days difference between two dates?

    I'm running Crystal v12.
    We use a date field in our SQL database that we use to store the client's year end date.
    As the year end date (date and month) doesn't change for a client, the year end date field in all of our reports is set to just show the DD/MM part. Over the years as new clients are set up we just enter the date and month - the year part is irrelevant although as in all date fields the year is automatically entered.
    Doing it this way means that we don't have to adjust the year end year part each year. We just use the DD/MM part.
    I need to create a formula that works out the number of days there have been (i.e. the difference) from the current date to the year end date. It MUST EXCLUDE the year however.
    For example:
    Year End Date = 30/04/03
    Current Date = 25/05/10
    Days Difference (EXCLUDING year) = 25
    Days Difference (including year) = 2582
    Year End Date = 31/03/09
    Current Date = 25/05/09
    Days Difference (EXCLUDING year) = 55
    Days Difference (including year) = 420
    If you include the year part then working out day difference is simply a case of creating a formula that subtracts the year end date from the current date (CurrentDate - {tblClient.YearEnd}.
    HOWEVER I need to exclude the year part.
    Can anyone tell me the formula or best way to do this?
    Thanks in advance.
    Edited by: BadBoy House on May 25, 2010 3:15 PM
    Edited by: BadBoy House on May 25, 2010 3:15 PM

    Hi
    You can try this
    datevar e := date(year(currentdate),month({tblClient.YearEnd}),day({tblClient.YearEnd}));
    numbervar num_days := datediff("d",currentdate,e)
    Create a datevar called e that uses the original month and day numbers for {tblClient.YearEnd} but uses the year of the current date
    Then just datediff on e to get the number of days between the two dates
    I hope i understand your problem and that this helps
    Best regards
    Patrick

  • Store xml data with difference dtd in the same xmltype column?

    Hi, all!
    I want to know, whether i can store the xml data with difference DTD in the same xmltype column.
    thank you for your help
    rabbit

    As long as the column is not based on an XML Schema

  • Query Question - "Number of Days" column possible? (for SAP Business One)

    Question: Is it possible to create a column in a Query that shows the number of days (from today) until a specified date (from another field in the system)? If so, how?
    An example of what the Query code would look like would be incredibly helpful!
    Edited by: Irma Christoffel on Sep 23, 2010 2:35 PM

    Do you think somethong like this?
    SELECT T0.[DocNum],T0.[CardName], T0.[DocType], T0.[DocDueDate],
    datediff(d ,getdate(),T0.[DocDueDate]) 'remaining days'
    FROM ORDR T0

  • Number of days left

    Is it possible to show the number of days left from a date too 'sysdate' ? So as an example, if there was column with value of 'due_date' of 23/11/2013 and I wanted to see how may days there where left between SYSTDATE (today) and the 23/11/2013 (which would be two).. How can I do this as an SQL ?

    Hi,
    Sure:
    SELECT  DATE '2013-11-23' - TRUNC (SYSDATE)  AS days_left
    FROM    dual;
    If d1 and d2 are DATEs, then d1 - d2 is the NUMBER of days between them.  If d1 is earlier than d2, this will be a negative number.
    Remember, all DATEs in Oracle include hours, minutes and seconds.   In the query above, the hours, minutes and seconds are not specified in the DATE literal DATE '2013-11-23', so they default to 00:00:00.
    If SYSDATE is 00:00:00 on November 21, 2013, then the difference between that DATE and SYSDATE is exactly 2.000000.
    If SYSDATE is a minute or so after midnight on November 21, 2013, then the difference will be around 1.99.
    If SYSDATE is 06:00:00 on November 21, 2013, then the difference will be 1.75 days
    The query above, using TRUNC gives the differences as exactly 2 when SYSDATE is any time on November 21, 2013.
    Oracle calls this Date Arithmetic .
    For more, look up "date arithmetic" in the SQL Language manual:
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/sql_elements001.htm#SQLRF00208

  • Number of days between 2 consecutive invoice

    Can you help my with a problem?
    I have a table with an Accountkey, and Invoice date:
    ACCOUNTKEY     | INVOICEDATE
    411.1     | 01.02.2012
    411.1     | 15.01.2012
    411.1     | 26.03.2012
    411.2     | 02.03.2012
    411.2     | 11.04.2012
    I need to find the number of days between 2 consecutive invoice.
    Like this:
    ACCOUNTKEY     | INVOICE_DATE     | PREVIOUS_DATE     | DIF(DAYS)
    411.1     | 15.01.2012     | 15.01.2012     | 0
    411.1     | 01.02.2012     | 15.01.2012     | 17
    411.1     | 26.03.2012      | 01.02.2012     | 54
    411.2     | 02.03.2012      | 02.03.2012     | 0
    411.2     | 11.04.2012      | 02.03.2012     | 41
    I introduced a new column "PREVIOUS_DATE" so I can make the difference between PREVIOUS_DATE and INVOICE_DATE.
    Tnx a lot

    Here one way to get it
    with my_data as
    (select  4111 accountkey,  to_date('01.02.2012','dd.mm.yyyy') INVOICEDATE from dual union all
    select  4111 ,  to_date('15.01.2012','dd.mm.yyyy') from dual union all
    select  4111 , to_date('26.03.2012','dd.mm.yyyy') from dual union all
    select  4112 , to_date('02.03.2012','dd.mm.yyyy') from dual union all
    select  4112 , to_date('11.04.2012','dd.mm.yyyy') from dual
    select
        accountkey
       ,invoicedate
       ,case
            when prev_date is null then invoicedate
            else prev_date
            end as prev
    from
    select
        accountkey
       ,invoicedate
       ,lag(invoicedate) over (partition by accountkey order by invoicedate) prev_date
    from my_data
    ACCOUNTKEY INVOICEDATE       PREV
          4111 20120115 00:00:00 20120115 00:00:00
          4111 20120201 00:00:00 20120115 00:00:00
          4111 20120326 00:00:00 20120201 00:00:00
          4112 20120302 00:00:00 20120302 00:00:00
          4112 20120411 00:00:00 20120302 00:00:00Mohamed Houri

  • Number of days customer is due to be maped in dunning notice PLD

    Hi All,
    In the Dunning Reprt PLD I want to print the number of days the Customer is due to company as the number of days due varries from customer to customer please give a solution. So that i want to map number of days from dunning wizard report in to the PLD.
    Regards & thanks for advance,
    Mobin.

    Hi Mobin
    One question first, the due days per customer does not make sense as there may be more than one document owing. I assume then that the oldest invoice must be used to calculate? This would be true at header level, but it will not be possible to place a field here to calculate from the rows. It might be possible to include a BP master UDF field here at print time, but this field would have to be updated manually on the BP masters with a query to get the maximum due date of open invoices and calculate their days overdue.
    For row level each document could have a number of days overdue and this should be rather easy to achieve. Add an extra column as formula field and use the following formula:
    ToNumber(F_203)-ToNumber(F_089)
    F_203 is my own hidden field at row level with the formula Date() in it. F_089 is the value date or due date on the row. You can also add a hidden field and refer to the database field you want to use for this date.
    I am still of course assuming that the dunning report you are referring to is the SAP standard dunning letter(s). If you are referring to a custom report, please let me know.
    Kind regards
    Peter Juby

  • How to get "Number of days" in a report on 0PM_DS02

    Dear BI Gurus,
    I need to build  a query on the PM DSO - 0PM_DS02 (MTTR/MTBR).
    The query has 0Equipment in the rows
    The fields Available Time | Breakdown TIme | Utilised Time in the columns for the time granularity selected.
    The field Breakdown Time is the calcaulted key figure Actual Outage Time from the DSO.
    The field Utilised Time  is a formula = Available Time - Breakdown Time.
    The issue I am facing is regarding the field Available Time.
    In the report the user needs time granularity in Month and Year.
    Basically the logic for the field Available Time = Number of days in the time period selected * 24
    where 24 = number of hours in a day.
    Now my issue is when the time granularity is month , the field should have the number of days in the month the user selects from the selection screen and when the time granularity is year, the field should have number of days in that year.
    Also during the query execution period, when the user changes the time granularity the report should also change the calculation for this field.
    (I can bring an extra field to the DSO, which will bring the available number of days in a month for each record)
    Can you please guide me how to map this scenario.
    Many Thanks in Advance,
    With Warm Regards,
    Vineeth

    Hi All,
    Waiting for your suggestion on this?
    With Warm Regards,
    Vineeth

  • FM to get the number of days in Year,month and days by giving number of day

    Hi ALL,
    This is quit differnt.
    I need to give input the 'start date' and the 'number of days' and get the total days from the start date in year,month and day format.
    for example.
    start date :01.01.2009
    number of days as 32
    then i should get
    years:0
    months :1
    days :1
    Pleas help me out.

    hi Anusha,
    first u pass the date and the days to the following fm you will get the result date....
    data:date type sy-datum,
          r_date(10) type c.
    date = sy-datum.
    CALL FUNCTION 'CALCULATE_DATE'
    EXPORTING
       DAYS              = '32'
       MONTHS            = '0'
       START_DATE        = date
    IMPORTING
       RESULT_DATE       = r_date
    write:/ r_date.
    then you need to pass the result date and the date to the following fm to get the required output...
    CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
        EXPORTING
          date1                   = r_date
          date2                   = date
        IMPORTING
          years                   = v_years
         months                 = v_months
        days                     = v_days
        EXCEPTIONS
          invalid_dates_specified = 1
          OTHERS                  = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    here u will get the difference in days,  months and year...
    i hope u wil get help from this...
    regards
    Ashu  Singh

  • Determine the number of days in a False period in a Temporal Boolean

    Hi all,
    I need to determiine the number of days based on a condition that lies on the gaps between the periods.
    My input consists of multiple periods. The length of the gap is the condition to determine the start date for summation. However, there can be multimple gaps between my instances that satisfy this condition and I need the last one that satisfies it.
    For example:
    period 1: 1-1-1990 until 31-12-1992
    period 2: 1-1-1994 until 31-12-1996
    period 3: 1-1-1998 until 31-12-1999
    period 4: 1-6-2000 until 31-12-2009
    The condition for the start date is the last gap greater than 1 year. In this example, the start date should be the start date of period 3: 1-1-1998, because this is the period after the last gap >= 1 year. Period 2 also has a previous gap of >= 1 year, but this period should NOT be selected.
    My first idea was to use a TBR function: to determine relevant periods (based on the gaps before and after), calculate the amount of days per relevant period and add those up. However, if I want to do that I need to calculate the number of days in the gaps and I don't see how to do that, since I cannot determine a day difference across periods (end date period 1 until start date period 2).
    Any help/ other solution ideas?
    Kind regards, Els

    This was an interesting puzzle which you can solve from a couple of different angles.
    Firstly, you can use inferred relationships to infer a relationship "the following periods" (ie. the periods that follow the current one). My rules looked like this:
    the period (the other period) is a member of the following periods if
       the other period start date > the period start date
    the period’s next start date = InstanceMinimum(the following periods, the period start date)From here it should be easy to see if there was a gap of more than a year, and find the most recent period after a year-long gap. Of course you need to deal with the situation of the last period, when there is no 'next' period, presumably you would use the date of assessment in that case, but I'll leave that as an exercise for the reader.
    A completely different way of doing it is to use the TemporalConsecutiveDays function to find a date where a gap of 365 days exists, then select periods in which there is a gap immediately before the start of that period. Here are some rules that :
    there is a period that applies if
       ExistsScope(the periods)
          TemporalOnOrAfter(the period start date) and
          TemporalOnOrBefore(the period end date)
    there is a year-long gap if
       TemporalConsecutiveDays(365, 365, there is not a period that applies)
    the period starts after a year-long gap if
       ValueAt(the period start date, there is a year-long gap)
    the start date for calculation = InstanceMaximumIf(the periods, the period start date, the period starts after a year-long gap)Hopefully one of these is suitable for your needs.
    cheers,
    Steve.

  • Count the number of days in the selected range using Customer exit

    Hi Experts,
    we have requirment where user is asking to add a column to report, which will have 'count of days for which key figure is having values' for each of the months and the Header would be 'Day Count'
    Please let me know if its possible using Customer exit?

    Hi,
    In our report we have two characteristics site no. and product and we have 6 key figures of type quantity and Input for the report is Fiscal year/period
    So in the report Key figures are populated with values for respective site no. and product combination
    Now the user wants new column in report which will have header u2018Day countu2019 and it should Simply count the number of days in the selected range that have a volume different than 0 for key figure
    Please let me know if more details are required

  • How can I calculate the maximum number of days between two dates in a range of dates?

    I have a column of dates spanning the couse of a few months.  I would like to know if I can calculate the maximum number of days between each row and display the highest number.  I currently have another column that calculates the days betwen the rows and I am currently just looking at the totals and highlighting the highest period.
    Is this possible?  Any help or suggestions are appreciated.
    Thank you,
    Trevor

    This sounds totally possible,  Can you post a screen shot of your table to make responding more focused?  If you mean you want to:
    A) compute the difference (in days) between two date in the same row, then
    B) find the max duration (in days)
    Here is my take on this problem:
    D2 = C2-B2
    select D2 and fill down
    F1=MAX(D)
    to perform the conditional formatting (to highlight the max duration) select column D, then set up conditional formatting as shown in the 1st image

Maybe you are looking for

  • New hard drive replacement on my MacBook Pro.

    I bought a new hard drive for my laptop but I do not have the disc to reboot the new hard drive, can someone help me?

  • How do I programmatically reference the current page in 902?

    Hello, How do I programmatically reference the current page in 902? The Portal Smart Text option for Current Page is not flexible enough, and I wish to create my own custom greeting using PL/SQL. Cheers, John

  • Hp dv7t 4100 cto entertainment notebook pc blu ray problem

     Hi i have a hp dv7t 4100 cto laptop .. i have windows 7 home premium os it read s all the disc i inserted.. but when i insert a new empty disc it is not at all reading or responding. the same thing happens when i insert blu ray discs i cannot write

  • Restructure Purchase Order Form?

    Hi all I am in learning phase of SAP BYD. I have task to restructure the Purchase order Form. Contact should be Purchase request and orders (WC) > Purchase order / Général tab Buyer responsible field Below Contact I want to put new label Service Serv

  • I cannot compile "C" source file on Mac OS X(10.8.2)

    Hi, I am trying to compile the C source filein terminal, using "cc" or "gcc" command. No luck. Later on, tried to ran the command, xcrun cc filename.c, the compiler gave an error about header files.