Difference between 2 date variables

I have a query that selects data based on :
WHERE START_DATE >= &BEGIN
AND start_date <= &END
I need to find the difference between these 2 dates in order to use the result in a calculation in the totals area in a rtf I have, but don't know how to do a datediff with variables. Is it possible?
Thanks

You are running into a problem casting your character variables into dates. As you can see here, it is not such a good idea to let the database do this for you...
WITH temp AS
SELECT SYSDATE start_date FROM dual
SELECT *
FROM   temp
WHERE START_DATE >= &BEGIN
AND start_date <= &END + 1;
Enter value for begin: '01-dec-07'
old   7: WHERE START_DATE >= &BEGIN
new   7: WHERE START_DATE >= '01-dec-07'
Enter value for end: '01-jan-08'
old   8: AND start_date <= &END + 1
new   8: AND start_date <= '01-jan-08' + 1
AND start_date <= '01-jan-08' + 1
ERROR at line 8:
ORA-00932: inconsistent datatypes: expected DATE got NUMBERBut if you wrap the character strings with to_date()....
WITH temp AS
SELECT SYSDATE start_date FROM dual
SELECT *
FROM   temp
WHERE START_DATE >= to_date(&BEGIN,'DD-MON-YY')
AND start_date <= to_date(&END,'DD-MON-YY') + 1;
Enter value for begin: '01-DEC-07'
old   7: WHERE START_DATE >= to_date(&BEGIN,'DD-MON-YY')
new   7: WHERE START_DATE >= to_date('01-DEC-07','DD-MON-YY')
Enter value for end: '01-JAN-08'
old   8: AND start_date <= to_date(&END,'DD-MON-YY') + 1
new   8: AND start_date <= to_date('01-JAN-08','DD-MON-YY') + 1
START_DAT
18-DEC-07And to be absolutely correct, you should actually use a format mask with a full YYYY and supply a full year with your variables.
Greg

Similar Messages

  • Difference between two dates, using Variables in reporting

    how to calculate the days difference between Delivery date and Billing date in reporting, using variables (SAP BW 3.5v)?

    Hi,
    If you want to do the arethmatioc operations with the date then you will have to declare the date as key figure in the cube and add it there and then update it with the date from R/3.
    You can use formula variable for this subtraction.
    Create a formula in the bex analyzer and then in the down you will get option for the formula varibale.Just make a replacement path varibale on this time characteristic for which yuou want subtraction.
    During creation use "key" in the display and "number" as the data type.
    If number is not working them you can use "date" type.
    Nothing alse needs to be done during the variable creation.
    Once you have made the formula inlcude it in the columns of the report.
    Thanks

  • Get Date Difference between 2 date values as days

    Hi,
    How to get the difference between 2 dates in number of days format. Say if i need the difference between 2012-08-23 and 2012-08-20 as 3
    Please help..

    Hi,
    You can do it in XSLT since the dates are in ISO 8601 format...
    http://www.w3.org/TR/NOTE-datetime
    Here is a sample XSLT...
    <xsl:stylesheet  version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:fn="http://www.w3.org/2005/xpath-functions">
    <xsl:template match="/">
    <xsl:variable name="date1" select="xs:dateTime(/root/date1)"/>
    <xsl:variable name="date2" select="xs:dateTime(/root/date2)"/>
    <xsl:value-of select="fn:days-from-duration($date2 - $date1)"/>
    </xsl:template>
    </xsl:stylesheet>The above XSLT will result *4* for the following input...
    <root>
    <date1>2012-01-11T00:00:00.000-05:00</date1>
    <date2>2012-01-15T00:00:00.000-05:00</date2>
    </root>You can test this example here...
    http://xslttest.appspot.com/
    Hope this helps...
    Cheers,
    Vlad
    It is considered good etiquette to reward answerers with points (as "helpful" - 5 pts - or "correct" - 10pts)
    https://forums.oracle.com/forums/ann.jspa?annID=893

  • Difference between two date in bex query

    Hi all,
    I need to do a difference between two date using formula variable processing type customer exit beaucause I must use factory calendar in the formula.
    How can I do it?
    Can you give me an example of the routine?
    Thanks a lot
    Gianmarco

    Hi,
    You can still use the same code to copy it and customize as per your need. All you need to do is to subract the dates using the class: CL_ABAP_TSTMP after converting to timestamp and resulting seconds you convert back to days....Please get help from the developers to do this...
    Also, ensure that you write back this difference value to your variable so you get it on the reports for your calculations...
    Cheers,
    Emmanuel.

  • Difference between two dates

    Hi
    I have two date fields in the ODS..Both are characterists
    1. Requested delivery date
    2. Actual shipment end date.
    I would like to create a calculated KF  field for the difference between two dates in a query.
    How can I accomplish it?
    Regards

    You have to make Expiration data as nav attribute and create a formula variable then only this date can be used in calculations.
    refer this How to...for the same
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/72f4a790-0201-0010-5b89-a42a32223ffc
    later you can try to calculate difference between dates!
    Re: calculating the difference between two dates
    Please search in forum with 'difference between two dates'.You will find lots of good posts on this issue!
    hope this helps
    Regards

  • Difference between 2 dates in milliseconds

    Hi all,
    I need to create a timestamp of difference in milliseconds
    between the date and time now and 00:00:00 01/01/1970.
    I am currently using:
    <cfset timeStamp = dateDiff("s",
    createDateTime(1970,01,01,00,00,00), REQUEST.dateTimeNow)*1000>
    but that gives me a value of 1.170170719E+012; however I
    require a string containing 13 numeric characters.
    Any advice appreciated.
    Thanks,
    Paul

    Paul / Adam,
    Thank you for your replies.
    > The DIFFERENCE between two dates is *not* a timestamp.
    It is just a value.
    > I presume what you want is the NUMBER of milliseconds
    since 0:00 1/1/1970.
    Yes, that is true. I am integrating the HSBC card payment
    interface and the name of the variable they are requesting is
    "timeStamp". I must have just used that as a description of what I
    was after rather than just the name.
    > "Determines the integer number of units by which date1
    is less than date2".
    >
    > dateDiff() will not do units of milliseconds, but it
    will do seconds. And
    > there's 1000ms in a second.
    So <cfset timeStamp = dateDiff("s",
    createDateTime(1970,01,01,00,00,00), REQUEST.dateTimeNow)*1000>
    should tell me how many seconds there are between 00:00:00 on
    01/01/1970 and the current date and time, then the *1000 should
    tell me the value in milliseconds?
    I have spoken with HSBC and they tell me that the specific
    value they are looking for from the timestamp is 13 numerical
    characters (e.g. 1170185487375), but the value being returned from
    my cfset above is 1.170170719E+012, which includes non numerical
    characters.
    The HSBC payment server is on a Linux server and my host is
    Windows. Are there any differences in the formatting of such a
    string?
    I cannot see anything I have missed on this.
    Any other suggestions?
    Thanks,
    Paul

  • Difference between two dates into server behaviors

    Good morning all,
    I'm trying to create a recordset using server behaviors and as I'm not an expert using php I'm completely lost...
    The problem is the following : I want to find into a table all the records where the difference between today date and their creation date (stored in that table of course) is greater than, let's say 30days. How can I indicate that into the variables field ?
    Many thanks in advance for your help !

    Many thanks !
    I was ignoring the DATE_SUB function and it does work in such a simple way… (with a closing parenthesis at the end)
    Thanks again !
    Best regards
    De : osgood_ [email protected]
    Envoyé : lundi 16 septembre 2013 15:59
    À : Berurier75
    Objet : Difference between two dates into server behaviors
    Re: Difference between two dates into server behaviors
    created by osgood_ <http://forums.adobe.com/people/osgood_>  in Dreamweaver support forum - View the full discussion <http://forums.adobe.com/message/5685549#5685549

  • Difference between 2 dates in form of years,months and days.

    Hi friends,
      i need one function module for finding difference between 2 dates and the output is
    no. of years
    no.of months
    no. of days.
    it means the input is begin date and end date
    output is no.of years,no.of months and no.of days.
    for example begin date is today i.e., 08/02/2008 (dd/mm/yyyy) and end date is 07/03/2008 then the output is
    no.of years -
      0,
    no.of months----
      1,
    no.of days----
      0.
    and one more example if begin date 08/02/2008
    (dd/mm/yyyy) and end date is 01/02/2008 then the output is
    no.of years -
    0,
    no.of months----
      0,
    no.of days----
    -7..
    Please help me it's very urgent

    Hi,
    Use FM HR_AUPBS_MONTH_DAY.
    It Calculate the years, months, days & cal days between 2 dates.
    Hi,
    The FM is 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
    Check the following example:
    DATA: EDAYS LIKE VTBBEWE-ATAGE,
    EMONTHS LIKE VTBBEWE-ATAGE,
    EYEARS LIKE VTBBEWE-ATAGE.
    PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,
    TODATE LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.
    call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
    exporting
    i_date_from = FROMDATE
    i_date_to = TODATE
    I_FLG_SEPARATE = ' '
    IMPORTING
    E_DAYS = EDAYS
    E_MONTHS = EMONTHS
    E_YEARS = EYEARS.
    WRITE:/ 'Difference in Days ', EDAYS.
    WRITE:/ 'Difference in Months ', EMONTHS.
    WRITE:/ 'Difference in Years ', EYEARS.
    INITIALIZATION.
    FROMDATE = SY-DATUM - 60.
    Also You can write your own function module for this..
    just extract day and month and year from the two dates and then get the difference.
    suppose date 1 - y1m1d1
    date 2 = y2m2d2
    data : y1(2) type n,
    m1(2) type n,
    d1(2) type n,
    y2(2) type n,
    m2(2) type n,
    d2(2) type n,
    y1 = date1(4).
    m1 = date1+4(2).
    d1 = date1+6(2).
    y2 = date2(4).
    m2 = date2+4(2).
    d2 = date2+6(2).
    then get the differnce between years and days and months and store them in ur variables
    Reward Points if found helpfull..
    Cheers,
    Chandra Sekhar.

  • Difference between Filter and Variables

    Hi Experts,
    What is the difference between Filter and Variables except user can give input dianamically in the case of Variables??
    Thanks in Advance!
    Sapna

    HI,
    Both works similarly ....but if the requirement is fixed means u know what data should be displayed in the query then u can use the filters....if u want to give that option to the Users then we create a variable and user can enter the required data which he wants to view.....once u define filters then only that particular restricted data will be displayed in the query out put....but incase of variables we are having the flexibility to view the data....
    Thanks/Tarak

  • DIFFERENCE BETWEEN THE DATA DECLARATIONS NVARCHAR2 AND VARCHAR2(x CHAR)

    CAN ANYONE HELP ME FIND THE DIFFERENCE BETWEEN THE DATA DECLARATIONS; NVARCHAR2 AND VARCHAR2(x CHAR), WHERE X IS THE SIZE OF DATA TO BE HELD WITH THE VARIABLE OR ATTRIBUTE

    Duplicate posting....
    Difference between nvarchar2(10) and varchar2(10 char )
    Difference between nvarchar2( 10) and varchar2( 10 char)
    Please refer also...
    Nvarchar2

  • Calculating the difference between 2 dates that ristrict 0CALDAY

    Hello.
    Is there an oppotunity to calculate the difference between 2 dates, that restrict the characteristic 0CALDAY.
    If i make the formula with
    1. type - replacement path
    2. interval use - difference
    than the difference could be calculated wrong(example 20070301 and 20070101 - result 201)
    Is there another way do solve the problem?
    Best regards,
    Andrey

    Hi,
    as you said, you need to create 2 formula variables.Both of them should have Replacement path as the preocessing type. And then use a formula to do the difference above 2 formula varibles.
    Now check these settings for both variables:
    <b>Replacement Path</b>
    Replace Variable with: <b>Key</b>
    For Intervals Use: <b>From Value</b>
    <b>Currencies and Units</b>
    Dimension ID: <b>Date</b>
    Then it should work
    Another link:
    http://help.sap.com/saphelp_nw04s/helpdata/en/03/6ba03cc24efd1de10000000a114084/frameset.htm
    regards
    marc
    assign points if it helped

  • What is the difference between delivery date and actual goods issue date?

    Hi ,
    Can you please tell me the difference between Delivery date and Actual goods issue date ?
    Delivery data can be be greater than goods issue date?
    Thanks,
    Ajay

    Hi Ajay,
                  Delivery date means its the original date on which the delivery should be done.Actual goods Issue date is the date on which goods to be delivered according to the purchase order.There can be delay in the delivery so we maintain 2 objects.
    Yes delivery date can be greater than Goods Issue date.
    Hope this clears
    Regards
    Karthik

  • As to the data type of the data type of the difference between two date type of datas

    Hi,
    I have a question about the data type of the difference between two date type of datas.
    There are two date type of datas as:
    SSHIPMENTS.RECEIVEDATETIME
    SSHIPMENTS.PROMISEDATETIME
    I try to use the following SQL Script in Oracle SQL*Plus as:
    SELECT CASE
    WHEN (SSHIPMENTS.RECEIVEDATETIME - SSHIPMENTS.PROMISEDATETIME) < '000 01:00:00.000' THEN 'OnTime'
    WHEN (SSHIPMENTS.RECEIVEDATETIME - SSHIPMENTS.PROMISEDATETIME) < '000 01:30:00.000' THEN '60-89 Minutes'
    ELSE '3+ Hours'
    END
    FROM SSHIPMENTS;
    The error message of "Invalid Number" for the '000 01:30:00.000' happens.
    I don't know if the data type of the interval is wrong.
    Many Thanks,
    Cathy

    SELECT CASE
    WHEN (to_char(SSHIPMENTS.RECEIVEDATETIME,'hhmiss') - to_char(SSHIPMENTS.PROMISEDATETIME,'hh24miss')) < '010000' THEN 'OnTime'
    WHEN (to_char(SSHIPMENTS.RECEIVEDATETIME,'hhmiss') - to_char(SSHIPMENTS.PROMISEDATETIME,'hh24miss'))< '000 01:30:00.000' THEN '60-89 Minutes'
    ELSE '3+ Hours'
    END
    FROM SSHIPMENTS;
    just try it out..

  • Difference between Invoice Date, GL Date and Accounting Date Oracle AP

    Hello,
    I have a question that might help a lot of people too later.
    I tried to run these queries
    select aia.INVOICE_ID
    from AP_INVOICES_ALL aia, AP_INVOICE_DISTRIBUTIONS_ALL aida
    where aia.INVOICE_ID = aida.INVOICE_ID
    and aia.INVOICE_DATE <> aida.ACCOUNTING_DATE
    select aia.INVOICE_ID
    from AP_INVOICES_ALL aia, AP_INVOICE_DISTRIBUTIONS_ALL aida
    where aia.INVOICE_ID = aida.INVOICE_ID
    and aia.GL_DATE <> aida.ACCOUNTING_DATE
    I can see that there are lot of results for these queries, where the Invoice Date is not equal to the Accounting date and the GL_Date of an invoice is not equal to the accounting date in the distributions table.
    So, what is the difference between these dates.
    And if I had to take the Invoice Accounting document entry date, which date do i have to take for these invoices in AP
    Thanks
    Bob

    Hi
    Let me try to explain this with an example.
    Suppose I buy some stationary from a vendor and he provides me with a detailed invoice of the goods puchased.
    In this case the invoice will always have a date printed on it and this date should ideally be entered in the invoice date at AP_INVOICES_ALL level.
    Now suppose the invoice happens to be received by me in february and for some reason I could not capture the invoice in my books in february and made a provision for the liabilities and close the books.
    However in march i want to book the invoice say on 10th of march in my books and pay the vendor the amount payable.(I Have to reverse the already provided liability in march to reverse the accounting effect).
    In this case my book entry date of invoice is the accounting date i.e. 10 March.
    In case of oracle, the accounting is maintained so that the invoice header hits the liability account while the invoice distribution hits the charge account(expense account so to say). And to gain more flexibility oracle provides date in both header and distributions to provide an option of booking liability and charge on different dates..
    As per the 11i checks there is no check on any of these dates except that accounting date at header and ditribution level must be in an open AP and GL period.
    Thanks
    MAV.

  • Difference between doc date,posting date and invoice date

    hi bw guys
    can someone give a brief on the difference between doc date,posting date and invoice date.and the invidual definitions
    thank you

    Hi,
    Posting Date: Date which is used when entering the document in Financial Accounting or Controlling. The posting date can differ from both the entry date and the doc date.
    Document Date: The document date is the date on which the original document was issued. Ex: Inv date, Bill date etc.,
    Invoice Date : Usually the date when goods are shipped. Payment dates are set relative to the invoice date.
    -Vikram

Maybe you are looking for

  • Applet working on JBuilder but not on appletviewer!!!!!

    I ve made a keybord.Here some buttons are missing. The user presses the buttons and shapes a word!When the jButton22 is pressed(Comparison button) the applet tells him if the result is true or false and displays an image(imageIcon foruser in jlabel f

  • Exception condition "CONVERSION_ERROR" raised.

    Hi, We have been getting short dumps in our production system daily. I was unable to locate the problem by looking at the dump. The dump says that CONVERSION_ERROR raised. Which application raised this exception? Again no clue on the same. Please fin

  • L355D DVD drive doesn't recognize some Photoshop CS2 disks

    I have 2 Toshiba Laptops, one with XP, one with Vista (L355D).  Neither one will even recognize my Adobe Photoshop CS2 install disk.  This Disk works fine in ALL other computers (3) I have tried it on.  Any Ideas???

  • HT4428 Is Samsung LS23CMZKFZ/ZA compatible with Apple TV

    Is Apple TV compatible with a Samsung  E2420L LCD 23.6 monitor model #  LS23CMZKFZ/ZA?

  • DHCP and FTP issues.

    I have a server setup running server 2012 R2 with DHCP and filezilla for FTP, and a desktop running windows 7. The server can ping the desktop, but the desktop can not ping the server, however the desktop can get a DHCP address from the server. How c