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;

}

Tags: Acrobat

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, months and year

    Hi all

    I'm using OBIEE 11 g. I have a line of dash for year (2010, 2011, etc.) and months (Jan, Feb,..., Dec). How can I get the number of days in a given month and year in my report?

    For example, if I choose to Jan & 2011, I'd get 31 and 356. And if I choose Feb & 2011, I would get 28 and 356.

    Thank you!

    I have something more good option here... Try to use this

    DAYOFMONTH (TIMESTAMPADD (SQL_TSI_DAY, DAYOFMONTH (CURRENT_DATE) *-1, TIMESTAMPADD (SQL_TSI_MONTH, 1, CURRENT_DATE)))

    This will give you the days for the month in progress (Oct 2011) after calculating the last day of each month... Similary dynamically pass the value Date or month... You will need to modify this function but shud be simple. Hope this helps :)

  • Get the first and the last day of the month...

    Hi friends,

    I'm trying to get the first and last day of a month and wants to implement that in the following code:

    SELECT COALESCE (Date_A, Date_B, Date_C)
    OF the double

    Here Date A and B are in Format DD MM YYYY (March 14, 2008)
    and Date like MM YYYY (March 2008)

    How can I get the Date_C as of March 1, 2008, OR March 31, 2008 if Date A and B are NULL?

    Thank you!

    Published by: user11095386 on April 23, 2009 10:45

    Hello

    In my previous message, I thought that you were starting with strings like ' 03 12 2009"and you want to display in the form of" 12 March 2009'.» If what you have is just the opposite, then simply reverse strings format in my first message. Add a comma, if you want, in the format string.
    I think that's what you want:

    COALESCE ( TO_CHAR ( TO_DATE ( Date_A, 'fmMonth DD YYYY'), 'MM DD YYYY')
             , TO_CHAR ( TO_DATE ( Date_B, 'fmMonth DD YYYY'), 'MM DD YYYY')
             , TO_CHAR ( TO_DATE ( Date_C, 'fmMonth YYYY'),    'MM DD YYYY')
             )
    

    Notice how, on the 3rd line, TO_DATE is called without DD in the format string:

    TO_DATE ( Date_C, 'fmMonth YYYY')
    

    When you do so, by default the day the 1st of the month, so that's all you need to do to convert the VARCHAR2 'March 2009' at the DATE of March 1, 2009.

    If you would like the last day of the month, not the first, when Date_C is selected, then use LAST_DAY:

    COALESCE ( TO_CHAR ( TO_DATE ( Date_A, 'fmMonth DD YYYY'), 'MM DD YYYY')
             , TO_CHAR ( TO_DATE ( Date_B, 'fmMonth DD YYYY'), 'MM DD YYYY')
             , TO_CHAR ( LAST_DAY ( TO_DATE ( Date_C
                                              , 'fmMonth YYYY'
                                )
                         )
                 , 'MM DD YYYY'
                 )
             )
    
  • I want to collect rain for the day, month and year; Can what formula I use?

    I want to collect rain for the day, month and year; What formula or expression that I can use.

    I use a Rain Wise product that converts impulses to an analog value.  The rain wise device can be

    "the value measure up to 1", 5", or 10".  I will be setting the unit at 10 inches in increments of 0.01 inch.

    What I would do is at each time increments of signal I would consider it as 0.01 then after reaching

    a period of time a day or a month, back to zero.

    Need some advice on this problem.

    How about you, using a counter to count the number of times where the signal is less than 0.01?

    For example,.

    Counter.Count = signal<=>

    The total number of rain is

    Counter * 10 + signal

    Use TimeOfDay or TimeOfWeek to reset the counter.

  • Get the firstday and last month lastday

    Hello

    How to get the first and last day of the last month?

    I've used this, but it returns January 1, 2010

    FirstDay:
    Select TRUNC (SYSDATE, 'year') of double

    LASTDAY:
    Select LAST_DAY (ADD_MONTHS (SYSDATE-1)) of the double

    You're close

    SQL> select TRUNC(ADD_MONTHS (SYSDATE, -1),'month') fom,
      2         LAST_DAY(ADD_MONTHS (SYSDATE,-1)) eom
      3  from dual;
    
    FOM       EOM
    --------- ---------
    01-DEC-09 31-DEC-09
    

    John

  • Set the calendar to display day, month and year

    In addition to the time of day, my computer began giving the day of the week (Monday) only instead of day, month and year as it did before. Tried to go back to 29/12/2014 or something similar without success.  Any suggestions?

    Hello

    Sorry for the late reply and I appreciate your patience.

    User profile corruption might have caused the problem. As a solution, I suggest to create a new user profile and check if the date format displays the same thing.

    To do this, see the link below.

    http://Windows.Microsoft.com/en-us/Windows/fix-corrupted-user-profile#1TC=Windows-7.

    It will be useful. Just answer us with the State, and we will be happy to help you.

  • How to get the second and third weekend of every month over a period of time?

    Hello

    No idea how to get the second and third weekend of every month on a given period without use of CLAUSE?

    Thanks in advance.

    Try it below,

    SELECT CASE WHEN TO_CHAR (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'DY') = 'SAT '.

    THEN ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)) + 1

    WHERE TO_CHAR (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'DY') = 'Sun '.

    THEN ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)) + 6

    Of OTHER NEXT_DAY (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), "SAT") + 1

    END as second_weekendday,

    BOX WHEN TO_CHAR (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'DY') = 'SAT '.

    THEN ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)) + 7

    WHERE TO_CHAR (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'DY') = 'Sun '.

    THEN ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)) + 7

    Of OTHER NEXT_DAY (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), "SAT") + 7

    END AS third_weekendday

    FROM (SELECT SYSDATE startdate,

    SYSDATE + 300 enddate

    THE DOUBLE)

    CONNECT BY LEVEL<=>

  • get the month and year of date type

    Hi all
    I need to get the month and year of type date.

    For example
    select to_date('2011-01-17', 'yyyy-mm-dd') from dual;
    Required result:
    01-2011
    Any ideas?

    Thanks in advance,
    Bahchevanov.
    select to_char(to_date('2011-01-17', 'yyyy-mm-dd'),'mm-yyyy') from dual;
    

    HTH

  • to get the month and year separated

    Hello

    I have the entry_date_fin of column (type of data-varchar2 (8))

    with values like Apr.-2008
    Feb-2009 etc.

    can I get the distinct month and year separated
    i tried select to_date(entry_date_fin,'MM') FROM  xyz  doesnt wrk
    kindly guide me

    Although you are (wrongly, IMO) storage of dates as strings, just use string manipulation...

    SQL> with t as (select 'FEB-2008' as txt from dual)
      2  --
      3  select substr(txt,1,3) as mnth
      4        ,substr(txt,5) as yr
      5  from t
      6  /
    
    MNT YR
    --- ----
    FEB 2008
    
    SQL>
    
  • How to get the scanning and fax utilities works from 2840 printer. Print function works from pc

    I changed my google chrome browser and I finally got my confiquered pc and printer. He is an all-in-one 2840 color laser jet. How do I get the scan and fax utilities to perform?

    It is useful to include the manufacturer and model number.

    What version of Windows you have, including the service pack?

    How the device is connected to your computer (USB, Ethernet, other)?

    Have you installed the software that came with your HP Color LaserJet 2840 AiO printer?

    If not, why?  If you did, what error messages you are seeing?  Please report messages completely, without paraphrasing.

    Start here: HP Color LaserJet 2820 and 2840 AiO products Series - first installation and install

  • problem to insert only month and year instead of the full date

    select b.penjara_id, p.penj_lokasi, a.no_daftar, b.episod, b.nama1,to_char(a.trkh_mula_prl,'dd/mm/yyyy') as trkh_mula_prl, to_char(bulan_proses,'mm/yyyy') as bulan_proses,
            b.epd, b.lpd
    from prl_daftar_proses a, senarai_pesalah b, penjara p
    
    where a.no_daftar=b.no_daftar
    and a.episod=b.episod
    and b.penjara_id = p.penjara_id
    and a.setuju_jplp is null
    and a.bulan_proses between to_date(:FROM,'dd/mm/yyyy') and to_date(:TO,'dd/mm/yyyy')
    
    
    order by b.penjara_id, a.bulan_proses,a.no_daftar
    Hi, can someone help me how I can register only the month and year of the value which have full day in the database?

    for example, the date is 18/09/2012, but I want to just insert 09/2012 as a parameter. If I want to insert only one setting, I can do... But I have problem when I want to insert two parameters...

    Lina saleh wrote:
    I already try before that and he invites me error like this...
    "name of the invalid host/identification variable.

    Change the name of the connection variable to: from_date and: to_date

    Is a reserved keyword.

  • How can I get the time and date appears on a sony cyber-shot camera

    How can I get the time and date appears on a sony cyber-shot camera

    Hi terpmarty,

    What is the model number of the Sony Cybershot camera?
    Instructions for superimposing the date and time are model specific. Some models do not have the ability to superimpose the date and time too. In such a case, you can use the supplied software Picture Motion Browser (PMB) or PlayMemories home (WPH) (Compatible with the Windows operating system) to print the date and time on pictures.

  • How do I get the toolbar and the sidebar to display in the Finder?

    How do I get the toolbar and the sidebar to display in the finder window? The choices are grayed out in the view.

    Hello!

    You clicked on dock finder, take the cursor to the top and clicked on display and then click on hide menu bar .it toolbar is hidden.

    See the side bar, tool bar again click on view - once again, click Show toolbar.

    Thank you!

  • How to get the phone and messages back in my dock apps? And for some reason, I discover now all my app pages from the middle of my phone and not at the top?

    How can I get the phone and messages apps in my dock? And for some reason, I discover now all my app pages from the middle of my phone and not at the top?

    Try

    Settings > general > reset > reset home screen presentation.

    Note: All other applications will be organised by alphabetical order.

Maybe you are looking for

  • My Web site layout, fonts, graphics are suddenly messed up.

    My site was beautiful in Firefox, as it always does in Chrome and IE. It wasn't until the other day when a customer told us that our site was horrible looking in its Firefox. Having no idea about how our site read in Firefox, we went to view the site

  • How to keep tabs of "constantly" "reloading" themselves?

    From the update of Firefox 4 tabs appear to keep repeatedly "reloading" themselves a little, quickly bogged down my computer when multiple tabs are open. How can I turn off the tabs of "constantly" (or often) 'reload' themselves? I prefer by far usin

  • HP VugenSA 11.50 (unhandled exception has occurred in your application.)

    Hello I use generator load runner virtual 11.5, after installation if I open VUgen, I get the below error. HP VugenSA 11.50 (unhandled exception has occurred in your application. If you click on continue, the application will ignore this error and at

  • Impossible to install the program, the error message

    This is the error message I get when trying to install a program. Ive tried to install it in clean boot mode I tried as admin Ive tried to startup repair as it was suggested that there could be something wrong with my system.  After trying to run the

  • Auto blackBerry 10 IAB on BBZ10?

    Recently upgraded to a BlackBerry smartphone Z10, and all is well, except one problem.  On my old blackberry (Bold), I was able to set up an automatic BCC (so for every email I sent some people were automatically THAT BCC would be), and I can't find