Number of days in a month

I have created a form with 2 date objects:

"Date1" is a date object in which the user will enter the first day of a month gave "MM/DD/YYYY";

I need "Date2" to calculate the last day of the month of 'Date1' ' MM/DD/YYYY ".

Obviously, the date displayed in Date2 will vary, because months contain a different number of days, so I can't just say '+ 30 '. Can someone help me with a JavaScript for the FomCalc code to achieve this?

Thank you!!!

Gene-O

Maybe you're view model is different from the trend in the script.

Here is an example of work form:

https://Acrobat.com/#d=rqvjWvn5WIBrWD * GLDRgfA

Tags: Adobe LiveCycle

Similar Questions

  • How to get the maximum number of days in a month?

    How to get the maximum number of days in a month?

    I use a dateField. where I can get the month. Now, I want to get the maximum number of days in a month.

    How can I get it?

    Please help me. and thanks in advance... []

    NET. RIM. Device.API.util
    Class DateTimeUtilities

    getNumberOfDaysInMonth (int month, int year)
    Returns the number of days in the specified month

    It took me like 10 seconds to find it in the API, I guess you spent more time writing the post...

  • Get the number of days in a month based on the month and year of fields

    I have a column in my form which lists the days in a month. I want to configure a hidden field that calculates the total number of days in a month, based on the month and year of the field inputs. The number of days will determine what appears on the column. For example, if I put 4 months, and 2016 in the field of the year, I get 30 in the hidden field. Thus, on the column 'Day', I'll have numbers 1-30. Or if I put 2 months and 2016 in the field of the year, I get the 29 in the hidden field. If the numbers 1-29 appears in the column 'day '.

    Found this on some forum javascript code:

    //Month is 1 based
    function daysInMonth(month,year) {
      
    return new Date(year, month, 0).getDate();
    }

    //July
    daysInMonth
    (7,2009); //31
    //February
    daysInMonth
    (2,2009); //28
    daysInMonth
    (2,2008); //29

    I do not know how to convert this code in JavaScript to adobe and don't really know how to use it. All I know how to do is to configure the field values for the field month and year as variables. I am a novice programmer and would appreciate it really all the help I can get. Thank you in advance!

    The code seems to be JavaScript and runs as needed by using the JavaScript console.

    I would like to consider making more general code, so if you have a date string that includes at least the month and year we could just call the function and get the number of days for that month.

    The following script will calculate the number of days in a month, by using at least the month and year values can display the result on the JavaScript console and all of the value field for the field that has this code as the custom calculation Script.

    function daysInMonth (oDate) {}
    return new Date (oDate.getFullYear (), oDate.getMonth () + 1, 0) .getDate ();
    }

    nMonth var = this.getField("Month").valueAsString; get the value of month;
    nYear var = this.getField("Year").valueAsString; get the value of the year;

    Event.Value = "";

    If (nMonth! = "" & nYear!) = "") {}
    var MyDate = util.scand ("' / mm/yyyy ', nMonth +" / "+ nYear); convert to date object;
    var nDaysInMonth = daysInMonth (MyDate); get the number of days;

    Console.Open (); Open the JavaScript console;

    Console.clear(); clear the console;

    Console.println ("Days in" + nMonth + ":" + nDaysInMonth); show days in month;

    Event.Value = nDaysInMonth; Set the value of the field;

    }

  • Need to obtain equal records the number of days of the month.

    Dear all

    My table and its data is given:

    Table name: Transaction_Master

    Trn_Num Trn_Dte
    1January 2, 2014
    2January 3, 2014
    3February 15, 2014
    4December 29, 2013
    5December 30, 2013
    and so on

    Now, I wish that my query must return equal records the number of days for each month of Trn_Dte. Be careful, I don't have Trn_Num column in my result. Its cities here only for explanation.

    It should, for example, records 31 to January 31 to December and 28 February.

    I tried following query but it passes loop and my db session gets hang.

    With T as

    (

    Select Distinct (Trn_Dte, 'Month') To_Char Trn_Mon, To_Number (To_Char (Last_Day (Trn_Dte), 'DD')) Tot_Day

    Of Transaction_Master

    Where Trn_Dte between parameter_1 and PARAMETRE_2

    )

    Select Distinct Trn_Mon, level

    T

    Connect by level < = Tot_Day

    Order By Trn_Mon, level

    Could you give me a solution for this case?

    Another solution for your exact needs. Try this and let me know in case of any problems. Because I changed the connection by the clause double itself.

    SELECT DISTINCT TRUNC (Trn_Dte, 'MY') + (lvl - 1)

    OF Transaction_Master aa (SELECT LEVEL lvl

    OF the double

    CONNECT BY LEVEL<= 31)="">

    WHERE Trn_Dte<= to_date('15-feb-2014','dd-mon-yyyy')="" ---="" add="">

    AND TO_CHAR(Trn_Dte,'MON') = TO_CHAR (TRUNC(Trn_Dte,'MON') + (lvl-1), 'MY');

  • Calculate fees that pay based on the number of days in a month

    Hello

    I'm writing the BR to fresh wages, based on the number of days in the month.

    Fix(Jan:DEC)

    "Salary" = ("Annual salary"-> "BegBalance" / 12) * "workforce";

    The existing calculation was ' wages divided by months no .of (12) ", now instead of number months wages that need to be calculated ("BegBalance"/ No..) OF DAYS IN THE MONTH) * 12.

    Can someone pls guide me, how to begin writing the BR for 'No. DAYS OF THE MONTH.

    You can do an admin enter number of days in the month. I remember CL reminding me the rhyme thirty days has September - Wikipedia, the free encyclopedia

    Jokes aside, you can use SQL to get the number of days. You will get different options for SQL and Oracle.

    If you want to continue to do this in BR then

    Fix(Jan:DEC)

    IF (@ISMBR (SEP) OR @ISMBR (Apr) OR @ISMBR (Jun) OR @ISMBR (Nov))

    ("Salary" = ("annual salary"-> "BegBalance" / 30) * 12) * "workforce";

    ELSEIF (@ISMBR (Jan) OR @ISMBR (Mar) OR @ISMBR (May) OR @ISMBR (July) OR @ISMBR (Aug))

    ("Salary" = ("annual salary"-> "BegBalance" / 31) * 12) * "workforce";

    ELSE (@ISMBR (Feb))

    IF (@Remainder($CurrYr/4) == 0)

    ("Salary" = ("annual salary"-> "BegBalance" / 29) * 12) * "workforce";

    ON THE OTHER

    ("Salary" = ("annual salary"-> "BegBalance" / 28) * 12) * "workforce";

    ENDIF

    ENDIF

    ENDFIX

    Concerning

    Celvin

    http://www.orahyplabs.com

    Post edited by: CelvinKattookaran

  • Function to return the number of days in a month?

    In one of my rules, I need to allocate an amount of benefits based on the number of days remaining in the calendar month.

    OPM does have a function that can provide me with the number of days in a calendar month?

    Thank you very much
    Isamu

    It is not a direct function to do this, however, it can be done with a bit of messing around. The following rules you will get the number of days of the month of the date of the date

    Basically, you get the first day of the month, add a month to the first day of the following month and then get the number of days between them, which will give you the number of days of the month of the date

    the month = ExtractMonth(the date)
    the year = ExtractYear(the date)
    the start of the month =MakeDate(the year, the month, 1)
    the start of the next month = AddMonths(the start of the month, 1)
    The number of days in the month = DayDifference(the start of the month, the start of the next month)
    

    These rules can be a little more compact, but it is basically how to do it.

  • How to get the number of days in a month of belonging to a range of dates

    Hi, I'm going crazy around a problem, I have 2 dates and one month I wanto to retrieve the number of days belonging to the months that fall within the range.

    for example:

    month of January 2011. begin_date = January 11, 2011, May 30, 2011 end_date result is 21
    month of January 2011. begin_date = December 11, 2010, result of end_date, January 10, 2011 10
    month January 2011 .begin_date = 2 February 2011, end_date may 25, 2011 result 0
    month of January 2011. begin_date = January 3, 2011, January 5, 2011 result DATE END 3

    and so on...

    I appreciate any suggestion
    Thank you


    Andrea

    Something like that... ?

    SQL> with t as
      2  (select  to_date('11/01/11','dd/mm/yy') from_dt,
      3           to_date('30/05/11','dd/mm/yy') to_dt,
      4           'Jan-11' mnth from dual)
      5  select least(last_day(to_date(mnth,'Mon-yy')),to_dt) -
      6         greatest(to_date(mnth,'Mon-yy'),from_dt) cnt
      7  from t  ;
    
           CNT
    ----------
            20
    

    If 0 is also expected...

    SQL> with t as
      2  (select  to_date('11/01/11','dd/mm/yy') from_dt,
      3           to_date('30/05/11','dd/mm/yy') to_dt,
      4           'Jan-11' mnth from dual union all
      5           select  to_date('11/01/11','dd/mm/yy') from_dt,
      6           to_date('30/05/11','dd/mm/yy') to_dt,
      7           'Jan-12' mnth from dual
      8           )
      9  select from_dt,to_dt,mnth,
     10         greatest(
     11              least(last_day(to_date(mnth,'Mon-yy')),to_dt)
     12              -
     13              greatest(to_date(mnth,'Mon-yy'),from_dt)
     14                 ,0) cnt
     15  from t;
    
    FROM_DT   TO_DT     MNTH          CNT
    --------- --------- ------ ----------
    11-JAN-11 30-MAY-11 Jan-11         20
    11-JAN-11 30-MAY-11 Jan-12          0
    

    Published by: JAC on February 9, 2012 19:22

  • number of days in the month

    Dear members,

    I have available dates,
    Let's say date1 = January 1, 2011"
    and date2 = April 15, 2011"

    My goal is to calculate the sum of the no. of days between this range.

    i.e.

    month = 01 days = 22
    month = 02 days-28
    month = 03 days = 31
    month = 04 days = 15

    so total days = 22 + 28 + 31 + 15 = 96 between individuals because of the date range.
    My goal is to have the figure 96 days that is the sum of the days of the month.



    Kind regards



    Teefu
    Developer

    Published by: teefu on July 21, 2011 10:09

    Hello

    If all you want is the total number of days, then you can simply subtract the earlier DATE of the last one, like this:

    SELECT     TO_DATE ( '15-04-2011'
              , 'DD-MM=YYYY'
              ) + 1 - TO_DATE ( '10-01-2011'     -- Jan. 10; '01-10-' would be Oct. 1
                        , 'DD-MM-YYYY'
                        )     AS days_diff
    FROM     dual;
    

    If you want to see a breakdown by month, here's one way:

    WITH     parameters     AS
    (
         SELECT     TO_DATE ( '10-01-2011'
                   , 'DD-MM-YYYY'
                   )     AS start_dt
         ,     TO_DATE ( '15-04-2011'
                   , 'DD-MM-YYYY'
                   )     AS end_dt
         FROM     dual
    )
    SELECT       TO_CHAR ( start_dt + LEVEL - 1
                , 'FMMonth YYYY'
                )     AS month
    ,       COUNT (*)     AS days
    FROM       parameters
    CONNECT BY     LEVEL <= 1 + end_dt - start_dt
    GROUP BY  TO_CHAR ( start_dt + LEVEL - 1
                , 'FMMonth YYYY'
                )
    ORDER BY  MIN (LEVEL)
    ;
    

    Output:

    MONTH                      DAYS
    -------------------- ----------
    January 2011                 22
    February 2011                28
    March 2011                   31
    April 2011                   15
    

    Published by: Frank Kulash, July 21, 2011 01:10

  • N ° of days in a month in Hyperion Essbase/Planning-For EN reports

    Hi all

    I know with your helpHow to reach no. Hyperion/Essbase days planning service hierarchy to create EN reports based on the number of days in a month


    Example: I need to create a new relationship with 3 columns and 1 row EN


    POV - year of the period, the scenario.

    Lines - Dimension entity


    Column1 - PTD Avg (account, Version, measure, Products_Type, products)

    Column2 - amount (counts, Version, measure, Products_Type, products)


    Column3 (formula column) - Eval ([Column2] /number of days per month* 36500 / [Column1] )


    Thanks in advance for the help!

    You can create a member of formula to account for the number of days in the month. It should look something like below. You must also include check year no.. of days in February (to assign 29 for leap years).

    IF (@ISMBR ("JAN") OR)

    ...

    ... etc.

    )

    'No days' = 31;

    ElseIf (@ISMBR ("FEB"))

    'No days' = 28;

    on the other

    'No days' = 30;

    endif;

    Kind regards

    Sunil

  • Query or logic to find several days through each month.

    Dear friends,

    I need your help to solve this problem.

    We have a now where we have to pay compensation to the employees based on their number of working days.

    Say, for example, if an employee has worked since March 3, 2012-April 5, 2012.

    We have a fixed value for a month 300 dirhams. But the number of days on s March 31 and number of days in the month of April are 30.

    So by compensation daily for March day would be 300/31 and April would be 300/30.

    We are looking for a logical opr query that calcluates first right number of days in each month (per month) and then calculate as below

    Number of working days in the month of March is 31-3 + 1 = 29

    Compensation of A1 = (300 * 29) / 31

    Number of working days in the month of April is 5 (must also find logical I guess)
    Allowance for A2 = (300 * 5) / 30

    Then A1 + A2.

    (E) would be the total quota when the number of months in all.

    Please guys any help would be greatly appricated.

    R

    Just a follow-up ;-)

    Note that you can almost get what you want with standard MONTHS_BETWEEN function [url http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions102.htm#i78039].
    But notice this quote from the documentation:

    >
    If date1 and date2 are the same days of the month or the last two days of the month, the result is always an integer. Otherwise the Oracle database calculates the fractional part of the result based on a month of 31 days and consider the time difference components date1 and date2.
    >

    It will always use one even if 31 days a month has fewer days.

    Then you could also implement the logic of my previous answer as your own function months_between implementation:

    create or replace function my_months_between (
       p_todate    date
     , p_fromdate  date
    )
       return number
    is
    begin
       return ((extract(day from last_day(p_fromdate))-extract(day from p_fromdate)+1) / extract(day from last_day(p_fromdate)))
            + (months_between(trunc(p_todate-1,'MM'),trunc(p_fromdate,'MM'))-1)
            + (extract(day from p_todate-1) / extract(day from last_day(p_todate-1)));
    end my_months_between;
    /
    

    I changed it to make it "compatible" with the standard function that it calculates up to but not including the parameter to date (which is correct when you are considering dates with time included, but I guess in your case, you have just date values.)

    Then, you can compare the results of the standard months_between with the new my_months_between:
    (Note that I have call the functions with the d2 + 1 to give the desired result of inclusion and to this day in the calculation).

    SQL> with testdata as (
      2     select date '2012-03-03' as d1, date '2012-04-05' as d2 from dual union all
      3     select date '2012-02-03' as d1, date '2012-05-02' as d2 from dual union all
      4     select date '2012-03-03' as d1, date '2012-03-10' as d2 from dual union all
      5     select date '2012-03-01' as d1, date '2012-07-31' as d2 from dual union all
      6     select date '2012-02-01' as d1, date '2012-03-01' as d2 from dual union all
      7     select date '2012-01-01' as d1, date '2012-03-25' as d2 from dual
      8  )
      9  --
     10  -- end of test data --
     11  --
     12  select months_between(d2+1, d1) std_months
     13       , 300 * months_between(d2+1, d1) std_allowance
     14       , my_months_between(d2+1, d1) my_months
     15       , 300 * my_months_between(d2+1, d1) my_allowance
     16    from testdata
     17  /
    
    STD_MONTHS STD_ALLOWANCE  MY_MONTHS MY_ALLOWANCE
    ---------- ------------- ---------- ------------
    1.09677419    329.032258 1.10215054   330.645161
             3           900 2.99555061   898.665184
    .258064516    77.4193548 .258064516   77.4193548
             5          1500          5         1500
    1.03225806    309.677419 1.03225806   309.677419
    2.80645161    841.935484 2.80645161   841.935484
    
    6 rows selected.
    

    For a large part of the data, both give the same result, especially when the two dates are in month of 31 days.
    To work from ' 2012-03-03' to '' 2012-04-05 standard service gives too little because it uses always 31 days, while my_months_between uses 30 days of April.

    "But note working from '' 2012-02-03 to 2012 - 05 - 02. He jumped 2 days in February and has worked 2 days in May - the standard function concludes he works precisely 3 months.
    But my_months_between computes fraction 27/29 months in February, then March and April like 2 months, and then the fraction 2/31 months in May - which gives a total of 2.99555061 instead of 3 months.

    Just something to be aware of ;-)

  • Number of days exclude sat'day and Sunday

    Hello

    I am able to get the number of days in the month starting today, but not able to exclude weekends. Please notify.

    My query


    SELECT TRUNC (SYSDATE) - TRUNC (SYSDATE, 'MM') OF DOUBLE


    I want to request something very simple as show below. Please, do not use login and keyword level because they are not supported by OBIEE.

    SELECT TRUNC (SYSDATE) - TRUNC (SYSDATE, 'MM') OF DOUBLE
    where wday not in ('Sam', 'Sunday');

    Thank you
    Jay

    What is OBIEE?
    You want to say it does not support "connection by ' and 'level '? These keywords are for the SQL engine and therefore has nothing to do with your frontend.

    The correct solution would be something like:

    SQL>   select count(*)
      2    from (select sysdate + l trans_date
      3          from (select level - 1 l from dual connect by level <= ((sysdate+7) - sysdate)))
      4          where to_char(trans_date, 'dy') not in ('sat', 'sun');
    
      COUNT(*)
    ----------
             5
    
    SQL> 
    
  • Count of the number of days in a calendar month according to the year

    Hi all

    On my table, column 1 is the list of months over several years.

    Column 2 is the activity number od each month.

    Column 3 I want an average rate of activity per day during the month, which should be: (C2 / number of days according to C1) %

    Problem: I can't find a fomula give me the number of days, particularly in February when the year is leap.

    Any help is appreciated.

    Thank you all,

    Lopez

    PS: by the way, with this new version of Apple Comunity I seem to have lost my previous questions about the numbers.

    Hey Lopez,

    EOMONTH(A1,0) (end of month) will GET help you.

    Column B is Date & time format to display only the month and year (actually the 1st of the month, but the day is not displayed).

    Formula in C2 (fill down)

    = EOMONTH(B2,0)

    The end of the month 0 months later.

    Formula in D2 (fill down)

    = DAY (C2)

    February 2015 (non-leap years) shows 28

    February 2016 (leap year) shows 29

    Kind regards

    Ian.

  • Number of days remaining in the month

    Hi guys,.

    I'm looking to create a function that returns the number of working days (Monday to Friday) between sysdate and the last day of the month.

    If someone has done something similar.

    I tried the following:

    < code >

    CURSOR days_c

    IS

    SELECT THE LEVEL

    , to_char (LAST_DAY (ADD_MONTHS (SYSDATE-1)) + LEVEL,'Dy DD-Mon-YYYY "") AS DOW - day of the week

    OF the double

    WHERE ROWNUM < = EXTRACT (DAY FROM LAST_DAY (SYSDATE))

    CONNECT BY LEVEL = ROWNUM;

    v_cnt NUMBER: = 0;

    BEGIN

    FOR days_r IN days_c

    LOOP

    To_char (days_r.DOW) NOT AS "Sat %" If GOLD to_char (days_r.DOW) NOT LIKE '% of Sun '.

    - AND to_date (days_r.dow) > sysdate

    THEN

    v_cnt: = v_cnt + 1;

    END IF;

    END LOOP;

    RETURN v_cnt;

    < code >

    At the present time, IF logic around the days_r.DOW does not work as I am also bad to only return the greater these days but less dates at the end of the month.

    Thanks in advance

    Chris

    Try this

    SQL > with input_data
    2 as
    (3)
    4. Select sysdate current_day
    5, last_day (sysdate) last_day
    6 double
    7)
    8. select count (*)
    9 of)
    10. Select current_day + (level - 1) d
    input_data 11
    12 connect
    13 by level<= last_day="" -="" current_day="" +="">
    14          )
    15 where to_char (d, 'fmday') not in ('Saturday', 'Sunday');

    COUNT (*)
    ----------
    20

  • How to calculate the number of days/weeks/months between 2 dates?

    Hello

    I would like to know how to calculate the number of days/weeks/months between 2 dates in OBIEE 11 g, for example, I have 26/05/2013 and 19/05/2013, then I want to get 7 days.

    Thank you!
    Jamie

    Hi Jamie,

    Through this links...

    http://www.bravesoft.com/blog/?p=682
    http://twobiee.blogspot.in/2012/01/working-with-date-differences.html

    Mark as correct it allows u...
    Thank you...

  • Number of days between two Dates in the Correct month

    I am trying to write a SELECT statement that returns the number of days spent on a project.

    Here's my problem. I have a table with several columns of date (start_date, end_date, etc.) as well as several other columns. Here is an example of the table.

    PROJECT... START_DATE... END_DATE
    123 ................. 1ST JANUARY 13... 15 JANUARY 13
    456 ................. 25 JANUARY 13... FEBRUARY 5, 13
    789 ................. 30 JANUARY 13... FEBRUARY 5, 13
    999 ................. 1ST FEBRUARY 13... FEBRUARY 8, 13

    I'm counting the number of days spent on projects in each month. For example, with the above data, I would come back...

    MONTHS... PROJECT_DAYS
    Jan ............. 24
    Feb ............. 18

    I tried to use a CASE statement, but I'm having a hard time to understand. Any help would be greatly appreciated!

    Published by: 987079 on February 8, 2013 13:12

    An option would be something like

      1  with project as (
      2    select 123 project_id, date '2013-01-01' start_date, date '2013-01-15' end_date from dual union all
      3    select 456, date '2013-01-25', date '2013-02-05' from dual union all
      4    select 789, date '2013-01-30', date '2013-02-05' from dual union all
      5    select 999, date '2013-02-01', date '2013-02-08' from dual
      6  ),
      7  all_days as (
      8    select start_date + level - 1 dt
      9      from (select min(start_date) start_date,
     10                   max(end_date) end_date
     11              from project)
     12   connect by level <= end_date - start_date + 1
     13  )
     14  select trunc(dt,'MM'),
     15         count(*)
     16    from all_days ad
     17         join project p on (ad.dt between p.start_date and p.end_date)
     18   group by trunc(dt,'MM')
     19*  order by trunc(dt,'MM')
    SQL> /
    
    TRUNC(DT,'MM')        COUNT(*)
    ------------------- ----------
    2013-01-01 00:00:00         24
    2013-02-01 00:00:00         18
    

    Justin

Maybe you are looking for