Day between?

Hi all

I need the date. I will give you the date as this June 13, 2014.

I need to print exactly one month before the date as December 5, 2014.

I need output like this:

13/06/2014

06/12/2014

..

..

..

..

...

05/12/2014.

all 31 days, I need to print. pls help me...?

"I want this output using the table"DOUBLE"

SQL > select to_date (June 13, 2014 "," dd-mm-yyyy')-level + 1 dt

2 double

3. connect by level<=>

DT

-------------------

13/06/2014 00:00:00

06/12/2014-00:00:00

06/11/2014 00:00:00

06/10/2014 00:00:00

06/09/2014 00:00:00

06/08/2014-00:00:00

06/07/2014 00:00:00

06/06/2014 00:00:00

06/05/2014 00:00:00

06/04/2014 00:00:00

06/03/2014 00:00:00

06/02/2014 00:00:00

06/01/2014 00:00:00

31/05/2014 00:00:00

30/05/2014 00:00:00

29/05/2014 00:00:00

28/05/2014 00:00:00

27/05/2014 00:00:00

26/05/2014 00:00:00

25/05/2014 00:00:00

24/05/2014 00:00:00

23/05/2014 00:00:00

22/05/2014 00:00:00

21/05/2014 00:00:00

20/05/2014 00:00:00

19/05/2014 00:00:00

18/05/2014 00:00:00

17/05/2014 00:00:00

16/05/2014 00:00:00

15/05/2014 00:00:00

14/05/2014 00:00:00

31 selected lines.

Alternatively, exactly one month before the date of entry:

SQL > select to_date (June 13, 2014 "," dd-mm-yyyy')-level + 1 dt

2 double

3. connect by level<= (to_date('13-06-2014',="" 'dd-mm-yyyy')-="" add_months(to_date('13-06-2014',="" 'dd-mm-yyyy'),="">

DT

-------------------

13/06/2014 00:00:00

06/12/2014-00:00:00

06/11/2014 00:00:00

06/10/2014 00:00:00

06/09/2014 00:00:00

06/08/2014-00:00:00

06/07/2014 00:00:00

06/06/2014 00:00:00

06/05/2014 00:00:00

06/04/2014 00:00:00

06/03/2014 00:00:00

06/02/2014 00:00:00

06/01/2014 00:00:00

31/05/2014 00:00:00

30/05/2014 00:00:00

29/05/2014 00:00:00

28/05/2014 00:00:00

27/05/2014 00:00:00

26/05/2014 00:00:00

25/05/2014 00:00:00

24/05/2014 00:00:00

23/05/2014 00:00:00

22/05/2014 00:00:00

21/05/2014 00:00:00

20/05/2014 00:00:00

19/05/2014 00:00:00

18/05/2014 00:00:00

17/05/2014 00:00:00

16/05/2014 00:00:00

15/05/2014 00:00:00

14/05/2014 00:00:00

31 selected lines.

Tags: Database

Similar Questions

  • Find the number of days between the dates...

    Hi friends,

    I am new to this development of blackberry applications so I do not know how to find the number of days between two days. Y at - there any API is avilable otherwise we have to write our own code. In fact, I tried GregorianCalendar but I get error that cannot find the symbol but I already imported net.rim.device.api.util and package java.util also... Please give an idea how to solve this problem.

    with respect,

    s.Kumaran.

    Use DateField class instances to represent dates on the screen.

    And your code will be as follows:

    long date1 = date1DateField.getDate ();

    long date2 = date2DateField.getDate ();

  • Dynamic calculation of the number of days between two dates in a table

    Hello

    I'm working on request where I dynamically calculate the number of days between two dates in a table.

    The calculation must be dynamic, i.e., when I recover the Start_date and End_date and move to the field following (call_duration) in the same row, the difference must be calculated dynamically in this area and make sure the field read-only.

    APEX version: 5.0

    Hi BO123,

    BO123 wrote:

    Hello

    I'm working on request where I dynamically calculate the number of days between two dates in a table.

    The calculation must be dynamic, i.e., when I recover the Start_date and End_date and move to the field following (call_duration) in the same row, the difference must be calculated dynamically in this area and make sure the field read-only.

    APEX version: 5.0

    one of the way to do this by calling ajax on change of end_date.

    See the sample code given below to fetch the resulting duration and making the field read only after calculation

    Step 1: Change your page

    under CSS-> Inline, put the code below

    .row_item_disabled {
      cursor: default;
      opacity: 0.5;
      filter: alpha(opacity=50);
      pointer-events: none;
    }
    

    Step 2: Create on demand Ajax process I say CALC_DURATION

    Please check Procces Ajax, see line 6.7 How to assign a value to the variable sent by ajax call

    Declare
      p_start_date  date;
      p_end_date    date;
      p_duration number;
    Begin
      p_start_date  := to_date(apex_application.g_x01);
      p_end_date    := to_date(apex_application.g_x02);
    
       --do your calculation and assign the output to the variable p_duration
      select p_end_date - p_start_date into p_duration
        from dual;
    
      -- return calculated duration
      sys.htp.p(p_duration);
    End;
    

    Step 3: Create the javascript function

    Change your page-> the function and the declaration of the Global Variable-> put the javascript function

    You must extract the rowid in the first place, for which you want to set the time, see line 2

    assuming f06, f07 and f08 is the id of the start date, and end date columns respectively, and duration

    See no line no 8 how set the value returned by the process of ajax at the duration column

    Replace your column to the respective column identifiers in the code below

    function f_calulate_duration(pThis) {
      var row_id  = pThis.id.substr(4);
      var start_date = $('#f06_'+row_id).val();
      apex.server.process ( "CALC_DURATION", {
      x01: start_date,x02: $(pThis).val()
    }, { success: function( pData ) {
    // set duration to duration column
    $('#f08_'+row_id).val(pData);
    // disable duration column
    $("#f08_" + row_id).attr("readonly", true).addClass('row_item_disabled'); }
    });
    }
    

    Step 4: choose the end date call the javascript function

    Go to report attributes-> edit your Date column end-> column-> Attrbiutes element attributes-> put the code below

    onchange="javascript:f_calulate_duration(this);"
    


    hope this helps you,

    Kind regards

    Jitendra

  • Days between two dates given

    Hi all

    I need the days between two dates given.

    Select to_date('25-mar-2014','dd-mon-yyyy') start_date, end_date to_date('30-mar-2014','dd-mon-yyyy')

    of the double

    Desired output:

    25

    26

    27

    28

    29

    30

    Thanks in advance.

    Kind regards

    Afzal.

    Select the level - 1 desired_output + to_number (to_char (start_date, 'dd'))

    of (to_date('25-mar-2014','dd-mon-yyyy') select start_date, end_date to_date('30-mar-2014','dd-mon-yyyy'))

    of the double

    )

    connect by level<=  end_date="" -="" start_date="" +="">

    DESIRED_OUTPUT
    25
    26
    27
    28
    29
    30

    Concerning

    Etbin

  • get delta days between dates

    Im trying to get the days between off_date and the following on_date for a user. (in the real of the table plenty of users with dates).

    Here is an example of the data.

    Oracle 11.2.0.3.0

    CREATE TABLE TEST_USER)

    NUMBER OF U_ID

    PERSON_NAME VARCHAR2 (50).

    ON_DATE DATE,

    date of off_date

    );

    INSERT IN TEST_USER (U_ID, PERSON_NAME, ON_DATE, OFF_DATE) VALUES (1, 'bob jones', TO_DATE (' 01/01/2013 ',' mm/dd/yyyy'), TO_DATE (' 01/10/2013 ',' mm/dd/yyyy'));

    INSERT IN TEST_USER (U_ID, PERSON_NAME, ON_DATE, OFF_DATE) VALUES (2, 'bob jones', TO_DATE (' 01/18/2013 ',' mm/dd/yyyy'), TO_DATE (' 01/27/2013 ',' mm/dd/yyyy'));

    INSERT IN TEST_USER (U_ID, PERSON_NAME, ON_DATE, OFF_DATE) VALUES (3, 'bob jones', TO_DATE (' 02/01/2013 ',' mm/dd/yyyy'), TO_DATE (' 01/03/2014 ',' mm/dd/yyyy'));

    INSERT IN TEST_USER (U_ID, PERSON_NAME, ON_DATE, OFF_DATE) VALUES (4, 'bob jones', TO_DATE (' 02/01/2014 ',' mm/dd/yyyy'), TO_DATE (' 02/02/2014 ',' mm/dd/yyyy'));

    insert into test_user (person_name, on_date, u_id, off_date) values (5, 'bob jones', to_date('02/02/2014','mm/dd/yyyy'), to_date (' 02/03/2014 ',' mm/dd/yyyy'));

    output should be:

    Bob jones 8 days

    Bob jones 5 days

    etc...

    Therefore the days between off_date and the next on_date

    Thank you.

    Hello

    Here's one way:

    SELECT person_name

    , (LEAD (on_date) OVER (PARTITION BY person_name - just guessing)

    ORDER BY on_date

    )

    -off_date

    ) || 'days' LIKE days

    OF test_user

    ;

    I guessed at what person_name role in this problem, and what is unique.

  • Find days between the dates expressed in days.

    Hi, I have a table with a structure similar to the following:

    LP1 TIME_EQ P_DAY LP2
    17.2

    0

    MONDAY
    16.8

    0.25

    TUESDAY
    17.03.5THURSDAY
    17.75FRIDAY
    17.41FRIDAY
    16.9.25SATURDAY
    17.1.25SATURDAY
    17.5SUNDAY

    Now I have two variables dates D1 = October 10, 2013 (Thursday) and D2 = 13 October 2013 (Sunday).

    How do I change my table such as only the lines covered between dates D1 and D2 are updated? In this case, the lines where the P_DAY (Thursday, Friday, Saturday, Sunday) I will use it for my slider, my query begins with this:

    CURSOR LOAD_PROF is

    SELECT LP1, TIME_EQ, P_DAY

    DE LOAD_PROFILE_TEST

    P_DAY in (? days between D1 and D2).

    I hope you get my point.  Thank you.

    First impression is that your table design seems incorrect to me. Why just store DAY? Why not the whole date?

    Says you can do this

    Select lp1

    time_eq

    p_day

    of load_profile_test

    where p_day in)

    Select to_char (start_date + (level 1), "fmDAY") day_

    de)

    Select to_date (October 10, 2013 ',' mon-dd-yyyy "") start_date

    , to_date (13 October 2013 ',' mon-dd-yyyy "") end_date

    of the double

    )

    connect

    by level<=  end_date="" -="" start_date ="" +="">

    )

    And finally the cursor? Try to do so in direct SQL. Do not loop through a cursor. If you share this part, we can give you best suggestion on the implementation of your real problem.

  • How to find days between two dates in days

    Hi, I want to get the days between two dates, expressed in days, how can I do this?  For example, I date i.e. 1 October 10, 2013 (Thursday) and 2 as October 13, 2013 (Sunday).  How can I get a production of:

    Thursday, Friday, Saturday and Sunday, which are the days between Oct. 10-13, 2013.  I hope you understand my point.  Thank you

    You can try something like this

    CURSOR LOAD_PROF is

    SELECT load_prof1, v_time_profile_day

    OF load_profile_test

    WHERE profile_day IN (select TO_CHAR(:day1+level-1,'Day')

    of the double

    connect by level<>

    );

    Kind regards

    S Pax

  • To find the months and days between 2 dates

    Hello

    I want to find the months and days between 2 dates.

    For example.

    1 - Date: August 25, 2013

    2 - Date: October 23, 2013

    If we consider each month 30 days, it should give

    August 25, 2013 to August 30, 2013 = 6 days

    01-Sep-2013-30-Sep-2013 = 1 month

    October 23, 2013 to October 30, 2013 = 8 days

    Total = 1 month and 14 days.

    Kindly help as soon as possible.

    Thanks and greetings

    Suresh

    Assuming that d2 > d1,.

    where d)

    Select sysdate d1, sysdate + 56 double d2

    Union all select to_date (March 1, 2013 ',' dd-mon-yyyy "") d1, to_date (March 31, 2013 ',' dd-mon-yyyy ') d2 double

    Union all select to_date (5 February 2013 ',' dd-mon-yyyy ') d1, to_date (March 31, 2013 ',' dd-mon-yyyy "") double d2

    Union all select to_date (February 25, 2013 ',' dd-mon-yyyy "") d1, to_date (March 23, 2013 ',' dd-mon-yyyy ') d2 double

    Union all select to_date (February 25, 2013 ',' dd-mon-yyyy ') d1, to_date (March 31, 2013 ',' dd-mon-yyyy "") double d2

    Union all select to_date (August 2, 2013 ',' dd-mon-yyyy "") d1, to_date (29 October 2013 ',' dd-mon-yyyy ') d2 double

    Union all select to_date (February 1, 2013 ',' dd-mon-yyyy "") d1, to_date (May 31, 2013 ',' dd-mon-yyyy ') d2 double

    Union all select to_date (25 August 2013 ',' dd-mon-yyyy "") d1, to_date ('03-Sep-2013', 'Mon-dd-yyyy') d2 double

    Union all select to_date (July 30, 2013 ',' dd-mon-yyyy "") d1, to_date (August 31, 2013 ',' dd-mon-yyyy ') d2 double

    Union all select to_date (July 31, 2013 ',' dd-mon-yyyy ') d1, to_date (August 30, 2013 ',' dd-mon-yyyy "") double d2

    Union all select to_date (July 31, 2013 ',' dd-mon-yyyy ') d1, to_date (3 August 2013 ',' dd-mon-yyyy "") double d2

    Union all select to_date (3 July 2013 ',' dd-mon-yyyy "") d1, to_date (August 31, 2013 ',' dd-mon-yyyy ') d2 double

    Union all select to_date ('31-08-2013', ' dd-mm-yyyy'), to_date('05-10-2013','dd-mm-yyyy') of the double

    Union all select to_date ('05-02-2013', ' dd-mm-yyyy'), to_date('31-03-2013','dd-mm-yyyy') of the double

    Union all select to_date ('05-02-2013', ' dd-mm-yyyy'), to_date('05-03-2013','dd-mm-yyyy') of the double

    Union all select to_date ('05-02-2013', ' dd-mm-yyyy'), to_date('05-02-2013','dd-mm-yyyy') of the double

    )

    Select d1, d2,

    1 + 30 * trunc (months_between (d2, d1)) + LESS (extract (day of d2), 30)-LESS (excerpt (d1 day), 30)

    + CASE when extracted (d2 day)< extract(day="" from="" d1)="" then="" 30="" else="" 0="" end ="">

    d

    D1 D2 DAYSBETWEEN

    ----------- ----------- -----------

    October 10, 2013 5 December 2013 56

    March 1, 2013 30 March 31, 2013

    5 February 2013 March 31, 2013 56

    February 25, 2013 March 23, 2013 29

    February 25, 2013 March 31, 2013 36

    August 2, 2013 29 October 2013 88

    February 1, 2013 may 31, 2013 120

    August 25, 2013 03 - Sep-2013 9

    July 30, 2013 31 August 31, 2013

    July 31, 2013 August 30, 2013 31

    July 31, 2013 3 August 2013 4

    July 3, 2013 August 31, 2013 58

    31 August 2013 5 October 2013 36

    5 February 2013 March 31, 2013 56

    5 February 2013 March 5, 2013 31

    February 5, 2013 February 5, 2013 1

    In my view, which corresponds to your rules.

  • Help the query to list all the days between MIN and MAX date in a table

    Hello

    Sorry, this may have already responded earlier, but I really struggled to find a previous response with the new provision of the RTO.

    In a DB 11 g, I date MIN and MAX in a table:

    {code}

    SELECT MIN (process_date) start_date, MAX (process_date) end_date FROM my_table;

    {code}

    I would get every day between these 2 dates. I mean even is there is no record in the table for a date.

    Is this possible?

    Thanks in advance,

    Olivier

    Hello

    Do you mean something like this?

    ranit@XE11GR2>> ed
    Wrote file c:\rb\1.sql
    
      1  with xx as
      2  (
      3      select
      4     to_date('05-06-2013','dd-mm-yyyy') min_d,
      5     to_date('20-06-2013','dd-mm-yyyy') max_d
      6      from dual
      7  )
      8  --
      9  -- end of test data
     10  --
     11  select
     12     min_d + level date_x
     13  from xx
     14* connect by level<=(max_d-min_d)
    ranit@XE11GR2>> /
    
    DATE_X
    -------------------
    06-06-2013 00:00:00
    07-06-2013 00:00:00
    08-06-2013 00:00:00
    09-06-2013 00:00:00
    10-06-2013 00:00:00
    11-06-2013 00:00:00
    12-06-2013 00:00:00
    13-06-2013 00:00:00
    14-06-2013 00:00:00
    15-06-2013 00:00:00
    16-06-2013 00:00:00
    17-06-2013 00:00:00
    18-06-2013 00:00:00
    19-06-2013 00:00:00
    20-06-2013 00:00:00
    
    15 rows selected.
    
  • JavaScript anomaly on the number of days between two dates

    Use ApEx 4.0, I found an anomaly in a javascript code that calculates the number of days between two dates, the current_date and the past_date. If the past and present is the or before March 10, 2013, and the current_date lies between 10 March 2013 and November 3, 2013, the number of days will be from 1 day to less than the actual number. Between November 3, 2013 and on 4 November 2013, the increments of number by 2, then the count will be accurate from this date forward.

    Here are some examples:

    March 10, 2013 = 69 days of December 31, 2012
    March 11, 2013 = 69 days of December 31, 2012
    March 12, 2013 = 70 days of December 31, 2012

    November 3, 2013 = 306 days in December 31, 2012
    November 4, 2013 = 308 days in December 31, 2012

    11 March should be 70 and 12 March should be 71. November 3 is 307 and 4 November corrects the number of fake, which began March 11.

    Change the past_date to March 10, 2013 produces the following:

    March 10, 2013 = 0 days of March 10, 2013
    March 11, 2013 = 0 days of March 10, 2013
    March 12, 2013 = 1 days of March 10, 2013

    But change the past_date to 11 March 2013, product of the correct numbers:

    March 11, 2013 = 0 days of March 11, 2013
    March 12, 2013 = 1 days of March 11, 2013
    March 13, 2013 = 2 days of March 11, 2013

    I would certainly all help to determine the cause of this anomaly. Here's the javascript code:

    var w1 = ($v ("P48_PAST_DATE"));
    W1 = (w1.toString ());
    vmon var = (w1.substr (3.3));
    vyr var = (w1.substr (7));
    var r = (vyr.length);
    If (r == 2)
    vyr. = (parseFloat (vyr) + 2000);
    vday var = (w1.substr (0.2));
    var y = (vmon.concat ("", vday, ",", vyr));
    y = Date.parse (y);

    var w2 = ($v ("P48_CURRENT_DATE"));
    var vmon2 = (w2.substr (3.3));
    var vyr2 = (w2.substr (7));
    var vday2 = (w2.substr (0.2));
    var x = (vmon2.concat ("", vday2, ",", vyr2));
    x = Date.parse (x);

    var numdays = (x - y);
    numdays = (Math.floor(numdays / 86400000));
    $s ("P48_NUMBEROFDAYS", numdays);

    Did you google for something like "javascript number of days between two dates. I think you will find the explanation to this observation:

    This method does not work correctly if there is an advanced economies jump between the two dates.

    There are examples available to calculate the difference between two dates.

  • How to find the number of days between 2 date elements in the XSLT file

    Hello

    I need to calculate the number of days between 2 date elements (type xs: date). Can you please direct me as to how I can do the same thing.

    I work in 11g and using XSLT 1.0. I tried several options but yet to get a solution for this. I think that this can be done also using XSLT 2.0, but who has not worked for me.

    Can someone please help with this problem, thanks in advance!

    Thank you
    Anju

    Hello

    Have you seen this message?
    Re: Get the Date difference between 2 values of date in days

    You can do in the XSLT file since the dates are in ISO 8601 format.
    http://www.w3.org/TR/NOTE-datetime

    Here is a sample XSLT...

    
    
    
    
    
    
    
    

    The XSLT above will result in * 4 * for the next entry...

    
    2012-01-11T00:00:00.000-05:00
    2012-01-15T00:00:00.000-05:00
    
    

    You can test this example here...
    http://xslttest.appspot.com/

    I hope this helps...

    See you soon,.
    Vlad

    It is considered good etiquette to the answerers rewards with points (as "useful" - 5 pts - or 'correct' - 10pts)
    https://forums.Oracle.com/forums/Ann.jspa?annID=893

  • find the difference in days between two dates

    Hello world

    I'm trying to find out the difference in days between two dates and the execution of the query that I'm passing

    SELECT TO_char(sysdate, 'dd/mm/yyyy') - TO_char('15/11/2011', 'dd/mm/yyyy') DAYS FROM DUAL

    the error I get is

    ORA-01722: invalid number
    01722 00000 - "invalid number."
    * Cause:
    * Action:

    Could someone please help.

    Thanks in advance

    user10636796 wrote:
    Hello world

    Thanks a lot for all the replies. I am trying to apply it in a statement to my table like this

    SELECT trunc (sysdate) - TO_char (date_last_recommended, ' dd/mm/yyyy') DAYS OF recommendation;

    SELECT trunc (sysdate) - TRUNC (date_last_recommended) DAYS OF recommendation;

  • counting the days between two dates

    I have 3 columns in my table

    date of purchase date sold days
    computer 24 April 09-11 May 09


    How can I write that a sql statement will help me to create a new column days and days between date bought and sold


    Thank you

    872959 wrote:
    I have 3 columns in my table

    date of purchase date sold days
    computer 24 April 09-11 May 09

    How can I write that a sql statement will help me to create a new column days and days between date bought and sold

    Thank you

    just subtract two dates & the difference will be in units of days

    SQL > select to_date('11-MAY-09','DD-MON-YY') - double TO_DATE('24-APR-09','DD-MON-YY');

    TO_DATE('11-MAY-09','DD-MON-YY')-TO_DATE('24-APR-09','DD-MON-YY')
    -----------------------------------------------------------------
    17

    Published by: sb92075 on July 19, 2011 10:26

  • Days between dates based on a 360-day calendar (10g)

    Hello
    does anyone know how to calculate days between dates based on a 360-day calendar (12 months to 30 days, used by merchants)? I use Oracle 10 g.

    Thank you for the help
    Best regards
    Carsten
    SQL*Plus: Release 10.1.0.4.2 - Production on Thu May 26 10:28:15 2011
    
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    
    Connected to:
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Beta
    
    ANTON@XE>with t as (
      2    select date '2011-04-04' as date_to, date '2011-02-02' as date_from from dual union all
      3    select date '2011-04-01', date '2011-02-02' from dual union all
      4    select date '2011-03-18', date '2011-02-02' from dual union all
      5    select date '2011-02-04', date '2011-02-02' from dual union all
      6    select date '2011-02-01', date '2011-01-31' from dual union all
      7    select date '2011-02-02', date '2011-02-02' from dual
      8  )
      9  select date_from, date_to
     10       , least( extract( day from date_to ), 30 ) - least( extract( day from date_from ), 30 )
     11       + 30 * ( extract( month from date_to ) - extract( month from date_from ) )
     12       + 360 * ( extract( year from date_to ) - extract( year from date_from ) ) days360
     13  from t
     14  /
    
    DATE_FROM       DATE_TO            DAYS360
    --------------- --------------- ----------
    02-FEB-11       04-APR-11               62
    02-FEB-11       01-APR-11               59
    02-FEB-11       18-MAR-11               46
    02-FEB-11       04-FEB-11                2
    31-JAN-11       01-FEB-11                1
    02-FEB-11       02-FEB-11                0
    
    6 rows selected.
    
    ANTON@XE>
    

    See also http://en.wikipedia.org/wiki/360-day_calendar

  • Number of days between two objects Oracle.jbo.domain.Date

    I have two objects Oracle.job.domain.Date:

    Date = StartDate (Date) CurrentRow.getAttribute ("StartDt");
    Date = CurrentDate (Date) this.getOADBTransaction () .getCurrentDBDate ();

    I want to find the number of days between StartDate and CurrentDate.
    I tried the CompareTo () function, but its does not not the desired results.
    Can someone let me know how I can find the number of days between StartDate and CurrentDate above?

    Concerning
    Hawker

    Hawker,

    Use the code below

    Date StartDate= (Date)CurrentRow.getAttribute("StartDate");
        Date CurrentDate = (Date)am.getOADBTransaction().getCurrentDBDate();
        java.sql.Date sdate = (java.sql.Date) StartDate.dateValue();
        java.sql.Date cdate = (java.sql.Date) CurrentDate.dateValue();
        int days = daysBetween(sdate,cdate );
    
      public int daysBetween(java.sql.Date d1, java.sql.Date d2){
         return (int)( (d2.getTime() - d1.getTime()) / (1000 * 60 * 60 * 24));
             }
    

    Kind regards
    GYAN

    Published by: Gyan on 27 March 2011 19:56

  • Calculate the difference in days between two Dates

    Hello

    I'm trying to understand how to calculate the difference in days between two dates using JavaScript in LiveCycle. (Minimum = JavaScript knowledge)

    Where 'Start_Date' and 'Current_Date' are the names of the two dates in the palette of the hierarchy. (the two Date/time field)

    * Current date is using the object > value > execution property > current Date/time

    I need a text or number field showing the difference in days. (Difference_in_Days)

    I noticed the following code is pretty standard among other responses:

    var

    Start_date = new Date (Start_Date);

    var

    Current_Date = new Date (Current_Date);

    var

    nAgeMilliseconds = Current_Date.getTime) - Start_date.getTime ();

    var

    nMilliSecondsPerYear = 365 * 24 * 60 * 60 * 1000 ;

    I know there is lack of code and code above are may not be not correct.

    Please notify.

    OK, that's because of the way that javascript and works of the calculate event.  The field will be filled with whatever the script resolves at the end of execution. Technically, your script does not have a value because the last thing you do is an assignment to a variable.  Change the last line as follows:

    Math.ABS ((firstDate.getTime)

    ((- secondDate.getTime (()) / (oneDay));

    (eliminate the variable assignment) and get rid of the app.alert.  Your script will "return" (have) regardless of the value of calculation from the East and which will be stored in the field.

Maybe you are looking for