Leap year problem

I cannot enter the date "February 29".
My normal way of specifying a date is "2-20", which gives me "February 20". This works up to and including "2-28". But entering "2-29" results in "1 feb 2029".
I have been unable to find a solution here.
Gunnar

Hello
Same thing with the French version.
I just entered the entire date: 29/02/2008 and bingo, it's a date.
It's only the parser deciphering the "incomplete date" which is a bit short
Yvan KOENIG (from FRANCE jeudi 31 janvier 2008 16:37:35)

Similar Messages

  • Validating Leap Years

    Is there a way of checking that an entered leap year date is valid?
    Eg. User enters 2/29/2001 which is not a valid date because 2001 was not a leap year.

    You should be able to use the SimpleDateFormat class to do this by issuing a setLenient(false) call. However, it does not seem to detect a leap year problem with the date 2/29. If you run the code below, you'll see that in the first section it correctly detects that 2/30 is a bad date, but in the second section, it does not detect 2/29 as a bad date. In section 3, you can see how an added test can detect the problem date.
            //Date validation
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            //Section 1 - correctly detects bad date
            try {
                String date = "2001-02-30";
                System.out.println("Here's the date - " + sdf.parse(date));
                sdf.setLenient(false);
                System.out.println("Here's the date - " + sdf.parse(date));
            } catch (ParseException pe) {
                System.out.println("Bad date");
            //Section 2 - does not detect bad date
            try {
                String date = "2001-02-29";
                System.out.println("Here's the date - " + sdf.parse(date));
                sdf.setLenient(false);
                System.out.println("Here's the date - " + sdf.parse(date));
            } catch (ParseException pe) {
                System.out.println("Bad date");
            //Section 3 - correctly detects bad date with additional check
            try {
                String date = "2001-02-29";
                System.out.println("Here's the date - " + sdf.parse(date));
                sdf.setLenient(false);
                //Additional test to compensate for leap year failure
                String dateString = sdf.format(sdf.parse(date));
                if (!dateString.equals(date)) {
                    System.out.println("Bad date");
                } else {
                    System.out.println("Here's the date - " + sdf.parse(date));
            } catch (ParseException pe) {
                System.out.println("Bad date");
            }

  • I bought a iphone 4 32gb verizon from apple store 4-7-11 had problem receaver exchanged 12-11 next one died no battery power works with cord dead without so 4-6-12 made apointment apple store emeryville ca they said leap year too late out of warrenty,

    i bought a iphone 4 32gb verizon from apple store 4-7-11 3:00pm,  had problem with  receaver no sound could not hear person i called  exchanged 12-11 exchanged iphone 4 32gb verizon died no battery power works with cord dead without so 4-6-12 made next available apointment apple store bay st.  emeryville ca for 4-7-12 1:15pm
    they said leap year added extra day so too late out of warrenty, sorry but can sell you new one  i called apple said same , a company that big should take care of customers the origanel receipt should of said under date of purchess warrnty to end date following year,

    That's strange, because no where in the iPhone's limited warranty does it state "365 days", but it does state 1 year. I think the only way they could get out of that is because of the battery, which is not covered by the warranty. HOWEVER, it is stated on AT&T's website that claims are handled from 31-365 days, which would explain why the Apple people acted as such. I know you have Verizon, but since it is (essentially) the same device, it's under the same warranty.
    http://www.att.com/esupport/article.jsp?cv=820&sid=KB64687#fbid=MG9VDbF7hX1
    Many people have had stories about issues happening as soon as their warranty expires, with products in general.
    I'd just consider upgrading, and selling your old one.

  • Problem with leap years in Calendar demo

    I've just looked at the Calendar demo component:
    http://developers.sun.com/prodtech/javatools/jscreator/reference/codesamples/samplecomps/calendar.html
    There is a little bug : it doesn't seem to manage leap years.
    Go to february 2008, and you won't the the 29th of February 2008 in the calendar.
    Please try to correct this bug quickly. It is a bad idea to let people get source code with bugs as a a demo.
    Thanks
    Thibaut REGNIER
    See TastePhone, my Open Source app made whith Java Studio Creator:
    http://www.club-java.com/TastePhone/J2ME/MIDP_mobile.jsp

    The Calendar Component does take account of the leap year.
    If you look at the code, it has
    if ((month == FEBRUARY) && (isLeapYear(year))) numCells++;Not sure what went wrong. I'll take a look at it.
    - Winston

  • HELP! Files won't open and previously had Firefox icon instead of DW icons!  Leap Year thing?

    Hi!  I went to update my website, which I do every night before the first day of every month and all the files had a FIrefox icon instead of the usual Dreamweaver one.  I have shut down, reinstalled DW MX 2004 but the files still do not open.  The icons have now changed to DW but they are not opening with right click, opening from Applications folder, double clicking the file, from get info and open with DW.  I am stumped. HELP!  Need to update for March 1st.
    Is it something to do with Leap Year 29th Feb?  Checked the clock in preferences but can't see how this affects it.
    Firefox is always updated but the latest version does not seem to be as efficient as previous upgrades.  We installed Chrome as well.  Do they interfere with each other?

    Hi Ken
    I wish the 7.1 updater download had helped but it didn¹t.  All the files
    were backed up before the installation, which went fine.
    Mac 10.5.8
    We used Disc Warrior to defrag the hard drive, which did not make a
    difference.
    We recently started using Chrome, so now have 3 browsers in the dock,
    Safari, Firefox and Chrome.  Do they interfere in any way with each other?
    The files, which I hadn¹t touched for a month as I update on a monthly
    basis, initially had the Firefox icon.
    Below is the message to send to Apple, which did not go through their report
    system!  A little disillusioned with the service!
    Model: iMac9,1, BootROM IM91.008D.B08, 2 processors, Intel Core 2 Duo, 3.06
    GHz, 4 GB
    Graphics: kHW_NVidiaGeForceGT130Item, NVIDIA GeForce GT 130,
    spdisplays_pcie_device, 512 MB
    Memory Module: global_name
    AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x8E),
    Broadcom BCM43xx 1.0 (5.10.91.22)
    Bluetooth: Version 2.1.9f10, 2 service, 0 devices, 1 incoming serial ports
    Network Service: Ethernet, Ethernet, en0
    Network Service: AirPort, AirPort, en1
    Serial ATA Device: WDC WD1001FALS-40K1B0, 931.51 GB
    Serial ATA Device: PIONEER DVD-RW  DVRTS08
    USB Device: Built-in iSight, (null) mA
    USB Device: Keyboard Hub, (null) mA
    USB Device: iLok, (null) mA
    USB Device: Apple Optical USB Mouse, (null) mA
    USB Device: Apple Keyboard, (null) mA
    USB Device: Deskjet 3840, (null) mA
    USB Device: BRCM2046 Hub, (null) mA
    USB Device: Bluetooth USB Host Controller, (null) mA
    USB Device: IR Receiver, (null) mA
    FireWire Device: d2 quadra (button), LaCie, 800mbit_speed
    Does not mean a thing to me.
    I am not late with updating the site, which is about New Zealand culture,
    month by month (www.englishteacher.co.nz). Probably only the third time I
    have been late since 2005. Not a huge amount of traffic, ~300 a month and
    free access to content but I would like to solve this problem.
    Could a reciprocal link have caused a problem?
    At my wits end.
    I really appreciate the help though.
    Cheers Yvonne
    From: Ken Binney <[email protected]>
    Reply-To: <[email protected]>
    Date: Wed, 29 Feb 2012 06:42:11 -0700
    To: Yvonne and Bill Hynson <[email protected]>
    Subject: HELP! Files won't open and previously had Firefox
    icon instead of DW icons!  Leap Year thing?
    Re: HELP! Files won't open and previously had Firefox icon instead of DW
    icons!  Leap Year thing?
    created by Ken Binney <http://forums.adobe.com/people/Ken+Binney>  in
    Dreamweaver - View the full discussion
    <http://forums.adobe.com/message/4236682#4236682>
    Not necessarily related, but did you also install the 7.1
    updater? http://www.adobe.com/support/dreamweaver/downloads_updaters.html
     Windows or MAC?
    Replies to this message go to everyone subscribed to this thread, not
    directly to the person who posted the message. To post a reply, either reply
    to this email or visit the message page:
    http://forums.adobe.com/message/4236682#4236682 To unsubscribe from this
    thread, please visit the message page at
    http://forums.adobe.com/message/4236682#4236682. In the Actions box on the
    right, click the Stop Email Notifications link. Start a new discussion in
    Dreamweaver by email
    <mailto:[email protected].ad
    obe.com>  or at Adobe Forums
    <http://forums.adobe.com/choose-container!input.jspa?contentType=1&container
    Type=14&container=2240>  For more information about maintaining your forum
    email notifications please go to
    http://forums.adobe.com/message/2936746#2936746.

  • ICal bug  -- leap year has broken reoccuring events

    Since last week , when there were 29 days in February instead of 28,  events in iCal which are re-occuring  (a meeting which occurs every month on the second Monday for example) is simply wrong.
    It is clear that this is an artifact of "Leap Year." The error compounds.
    In March in was off by one day -- scheduled on Tuesday instead of Monday. In April the error compounds... now scheduled on Friday in April.
    Events which were scheduled by data "appear" to be correct, but now I don't know that I can even trust them.
    This problem propigates through iCloud and infects my iPhone and iPads as well.
    iMac 10.7.3
    iPhone 5.1
    iPad 5.1
    Mac mini 10.6.8
    It turns out this Bug dates back to 2008!!!!!
    https://discussions.apple.com/message/6309125#6309125

    No. not really.
    I spent some time on the phone with Apple support and basically discovered that if I looked at the reoccurring event back in February (the previous month), it showed up correctly as an event being repeated as, in my case, "Custom, Every Month on the first Monday." However, then comparing that entry to the incorrect March entry, I noted the March entry was showing up as repeat "Every Month." (Which translated into every 30 or 31 days, looking at subsequent events.)
    Simply changing the bad March event back to the Custom "Every Month on the First Monday," and then applying it to the forward "worked around" the issue.
    We never did come up with any idea what caused the change. (i.e. the support person could find no references to any kind of similar problem.)
    I was told to go to "www.apple.com/feedback" and to select "iCal" from the list of "OS C Apps" near the bottom of the page, and report the problem.

  • How to Calculate Leap Year ago in OBIEE 11g

    Hi Gurus,
    I have one fact table and having one measure column. I have to calculate current year and Last year.
    Using Time series function (Todate,Ago) have calculated current year as well last year also.
    The problem is Current year is showing correct value only but Last year was showing wrong data.
    We found the problem is Leap year, last year FEB month is having 29 dates. Due to this we are getting wrong date.
    Kindly suggest me how to achieve this requirement.
    Thanks

    Hi Gurus,
    How to resolve Leap Year calculation in OBIEE 11g.
    The problems is Year Ago column.
    Please suggest me how to resolve this.
    Thanks

  • How to do a date validation with leap years

    I'm doing a date validation program in my Java class, and well it's pretty hard (for me that is). I have to be able to type in a date, have it say whether it's a leap year or not, and print out the number of days in the month. It seems pretty straight forward, but I get confused on trying to do the 'if else' statements and even the simplest things like getting the day prompting to work. >< The years I'm doing only goes through 1000 to 1999, so that's why those numbers are there. The program isn't complete, so if anyone could help show me what I'm doing wrong in the areas I'm working on then I'd appreciate it...and I'm still kind of in the basics of Java so if you do hint me with some code then I'd appreciate it if it was stuff that's not too advanced so yea.
    // Dates.java
    // Determine whether a 2nd-millenium date entered by the user
    // is valid
    import java.util.Scanner;
    public class Dates
    public static void main(String[] args)
    int month, day, year; //date read in from user
    int daysInMonth; //number of days in month read in
    boolean monthValid, yearValid, dayValid; //true if input from user is valid
    boolean leapYear; //true if user's year is a leap year
    Scanner scan = new Scanner(System.in);
    //Get integer month, day, and year from user
    System.out.print("Type in the month: " );
              month = scan.nextInt();
    System.out.print("Type in the day: " );
              day = scan.nextInt();
    System.out.print("Type in the year: " );
              year = scan.nextInt();
    //Check to see if month is valid
    if (month >= 1)
    month = month;
    else
    if (month <= 12)
    month = month;
    else;
    //Check to see if year is valid
    if (year >= 1000)
    year = year;
    else
    if (year <= 1999)
    year = year;
    else;
    //Determine whether it's a leap year
    //Determine number of days in month
    if (year == 1 || 3 || 5 || 7 || 8 || 10 || 12)
         System.out.println (Number of days in month is 31);
         else (year == 4 || 6 || 9 || 11)
         System.out.println (Number of days in month is 30);
    //User number of days in month to check to see if day is valid
    //Determine whether date is valid and print appropriate message
    // Dates.java
    // Determine whether a 2nd-millenium date entered by the user
    // is valid
    import java.util.Scanner;
    public class Dates
    public static void main(String[] args)
    int month, day, year; //date read in from user
    int daysInMonth; //number of days in month read in
    boolean monthValid, yearValid, dayValid; //true if input from user is valid
    boolean leapYear; //true if user's year is a leap year
    Scanner scan = new Scanner(System.in);
    //Get integer month, day, and year from user
    System.out.print("Type in the month: " );
              month = scan.nextInt();
    System.out.print("Type in the day: " );
              day = scan.nextInt();
    System.out.print("Type in the year: " );
              year = scan.nextInt();
    //Check to see if month is valid
    if (month >= 1)
    month = month;
    else
    if (month <= 12)
    month = month;
    else;
    //Check to see if year is valid
    if (year >= 1000)
    year = year;
    else
    if (year <= 1999)
    year = year;
    else;
    //Determine whether it's a leap year
    //Determine number of days in month
    if (year == 1 || 3 || 5 || 7 || 8 || 10 || 12)
         System.out.println (Number of days in month is 31);
         else (year == 4 || 6 || 9 || 11)
         System.out.println (Number of days in month is 30);
    //User number of days in month to check to see if day is valid
    //Determine whether date is valid and print appropriate message
    }

    Here are some helpfull hints for you:
    1. Your code is really hard to read, there are two main reasons for this. First, your indentation sucks. Second, you seem to be fascinated with saving two (ok four if you count the shift key) keypresses to avoid using { and }.
    2. Not using the brackets (you know { and } which you like to avoid) also is causing your code to do some stuff you don't realize or want to happen, or at least it would be if your code compiled.
    3. If statements require arguements, "year == 1" is an arguement, "3" is not an arguement. Each operator like the or operator ("||") is essentially a new if and requires a complete arguement. So the following code peice:
    if (year == 1 || 3 || 5 || 7 || 8 || 10 || 12)Literally translates to if year equals 1 or if 3 or if 5 or if 7 or if 8 or if 10 or if 12. Doesn't make much sense in english, and it doesn't make much sense in Java either.
    4. I am pretty sure "year" is not the variable you want in the code snippet above (the one used in hint 3), especially considering years 1, 3, 5, 7, 8, 10, and 12 are not between 1000 and 1999. You need to be really carefull not make these kind of mistakes when coding, because they are by far the hardest to track down and fix later since they don't really throw up any flags or anything at compile or run time. Take your time and think thuroughly about each line of code while coding it, it will save you tons of time in the long run.
    5. What exactly do you expect statements like "month = month;" to do? That translates as make month equal to month. Do you go to the bank and say " I have exactly $3.56 in my pocket, so I would like to deposite all $3.56 and then withdraw $3.56 and put it back in my pocket"? How do you think the teller would look at you? Teller would probably do it, but the teller would feel like he/she wasted time with you and that you are not really right in the head. Java feels the same way when you make it do the same thing, and you love to do it.
    6. Code like the following is all wrong, and for more reasons than pointed out in hint 5.
    if (month >= 1)
    month = month;
    else
    if (month <= 12)
    month = month;
    else;Let's say someone put 13 in as the month. It passes the first check because 13 is greater than or equal to 1. so month which is 13, now gets set to 13 (gee that was effective). Now we hit the else and things get confusing because you didn't use brackets or proper indentation (hint 1) so we don't know what your real intent was. Did you mean else do nothing, and the next if statement is then executed, or did you mean to just run the next if statement if the else condition was met? Fortunatly it doesn't matter here because the next if statement is failed anyways since 13 is not less than or equal to 12.
    So, we leave this code with month ebing 13, wait when did we add a 13th month to the calendar? Are you using the Jewish calendar? Could be, except even if I put 1234567 as the month your code would except it as valid, and I know no calendar with that many months. Try writing this in english first and translating it to jave, like i would probably say "if the month is greater than or equal to 1 and less than or equal to 12 then the month is valid." Course now what do you do if it is invalid? Hmm, maybe I would actually say "while the month is less than 1 or greater than 12 ask the user for the month" until they get it right.
    There are a few other problems, but most of them are probably things you haven't learned yet, and they are not show stoppers so we will let them fly. You already have a lot of work to do to make this better. But I do have one more really really big usefull hint for you:
    Never, ever, under any circumstances, should you ever ask in any way or even hint at asking for someone else to provide code solutions to your problems. So "so if you do hint me with some code then I'd appreciate it if it was stuff that's not too advanced " was a very bad thing to do, but fortunatly for you you followed it with proof you were trying to write the code yourself. Had the code you provided not been so full of problems it was obvious a beginner wrote it, you would probably have gotten much less cordial responses. I would seriously consider avoiding any implication of wanting code, at least until you become a regular poster here and people know you are not just looking to get your homework done for you.
    Hope some of this helps.
    JSG

  • Leap year bug adding days to a date?

    Please try this xquery:
    <dd>
    for $i in 0 to 4
    return
    <d>
    {xs:date('2008-12-29')+xs:dayTimeDuration(concat('P',$i,'D'))     }
    </d>
    </dd>
    If the starting date is a leap year date (eg: 2008-12-29), the result does not contain the 30rd of december!
    Is this a (known) bug or there is something wrong in my xquery?
    Thanks!
    Bye
    Mirko

    Hi Mirko,
    There's nothing wrong with your query - that looks like a bug in our date displaying code. Thanks for your analysis of the problem - I'll take a look into fixing it.
    John

  • Leap year issue

    Hi friends,
    I have a problem in one of the existing codes.
    The cancellation amount is calculated for a range of dates.
    Say the active line item has a start date of  01.03.2006 and end date of  01.03.2012 say (B).
    Now if a rejection/Cancellation is put on date 01.05.2007 (A), the current program is calculating a value
    based on the diffrence of days (B - A).
    then this cancelled amnt =  the no of cancelled days * (a constn value * 12 / 365).
    Now I want to modify my logic in such a way that the leap is also accounted.
    If I use the same dates , i realise that 2008 is the leap yr.
    So how can i modify my calculation for the range if it contains a leap yr.
    Please suggest something on this, as it will be really helpful.
    Thanks,
    Sapna Agarwal

    Hi Sapna,
        try to use the FM /SDF/CMO_DATETIME_DIFFERENCE, it will take care of the leap year, just pass the two dates for which you want the difference.
    CALL FUNCTION '/SDF/CMO_DATETIME_DIFFERENCE'
    EXPORTING
       DATE1                   = s_date
    *   TIME1                  =
       DATE2                   = e_date
    *   TIME2                  =
    IMPORTING
       DATEDIFF                = DATEDIFF
    *   TIMEDIFF               =
    *   EARLIEST               =
    EXCEPTIONS
       INVALID_DATETIME        = 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.
    if the gap is for more one year than you have to do the calculation year wise only, in this case use the fm '/SAPNEA/JSC_LEAP_YEAR' that which year is a leap year. And than go for a IF condition while calculating either it should be 365 or 366 days.
    With luck,
    Pritam.

  • Leap year without date objects

    I need to check to see how many leap years are between two user-inputted years and I can't use date objects. I figure I need to start with a for loop, but I get lost when to by the mod 4, mod 100, or mod 400. Any help?
    for(int l=cYear; l <= eYear; l++){
                        if(l%4 == 0){
                             if(l%100 == 0){
                   }also, if anyone is bored and really wants to give of themselves, I could use some more help with a pretty challenging-for-my-level program. Let me know.
    Message was edited by:
    kaluga

    yeah, he said like 20 times "one big main method, no
    other methods"He's a moron and should not be teaching CS or Java.
    Problems: 1. I am having trouble wrapping my mind
    around the logic,Meaning what? You described it--or was that just copy/paste of what's in the asisgnent? I gave you some pseudocode that's practically Java already.
    Just try it. Take your best shot and write some test cases and see how close you are.
    2. I don't know if this (below)
    syntax works.Try it. If the syntax is wrong, it won't compile.
    Once you get it to compile, then test it. Here's one reason why you'd want a separate method--you could test just that method by itself. As it stands, the easiest way to test it is to always give it just one year and see if you end up with the proper count--zero or one. If you give it many, you could end up with the right number by having the same number of false positives and false negatives.
    Once you know it works for one year, feed it a few lists of 5 or 10.
    btw jverd, I appreciate your helpYou're quite welcome. It looks like you're on the right track. Just don't be afraid to try stuff and see what happens, and then come back with specific questions about the specific problems you observed. :-)
    ---- Edit ----Or do like DrClap suggested and print each one. This way you can still test many at once.
    Note to self: Duh, Jeff.
    ---- ---- ----Message was edited by:
    jverd

  • Leap Year Calendar

    I am working on a project where the user enters a year. The string is then converted into an int and goes through a series of tests to see if it is a leap year or not. The problem I am having is when the user inputs letters when they are supposed to enter numbers. This gives the "java.lang.NumberFormatException" error. I used the try and catch code to make the user re input a year, but how do you make that into a loop. I want to make it so if the user keeps putting in letters, the computer keeps asking for numbers.
    this is my code so far:
    import javax.swing.JOptionPane; //import this at top
    public class finding_the_leap_year {
    public static void main(String[]args){
    int year = 0;
    {color:#ff0000}
    try{
    String inputValue = JOptionPane.showInputDialog("Input a year");
    year = Integer.parseInt(inputValue);
    catch(java.lang.NumberFormatException ex){
    while(????????????????????){
    System.out.println("Please enter a year");
    String inputValue = JOptionPane.showInputDialog("Input a year");
    year = Integer.parseInt(inputValue);
    }          }{color}
    if(year % 4 == 0)
    System.out.println(year + " is a leap year.");
    if(year % 100 == 0)
    if(!(year%400==0)){
    System.out.println(year + " is a leap year.");
    else{
    System.out.println(year + " is not a leap year.");
    Edited by: chibioj on Sep 29, 2007 12:50 PM
    Edited by: chibioj on Sep 29, 2007 12:51 PM

    Put more in the while loop. I sometimes use a boolean value such as dataValid or inputValid and set it to false. I only set it to true if the input entered is ok. It is set to true in the try block but AFTER the data is obtained and parsed. The code will only reach that line if the input is valid.
            String inData = "";
            boolean dataValid = false;
            while (!dataValid) // while we don't have a correct answer yet
                try
                    inData = JOptionPane.showInputDialog("Input a number");
                    if (inData != null)  // if they didn't press the cancel button
                        year = Integer.parseInt(inData);                   
                    dataValid = true; // won't get here if numberformatexception tripped
                catch (java.lang.NumberFormatException ex)
                    JOptionPane.showMessageDialog(null, "You didn't enter a valid year.  Please try again.");
            if (inData != null) // if cancel button not pressed on input dialog
                if (......Also, you have some logic errors in the rest of your code that need fixing.
    Good luck!

  • Leap Year Handling

    Hi All,
    I just want to get the exactly one year previous date by using the below query: for the leap year...
    update day
    SET FLAG = 'Y'
    WHERE PERIOD_DATE BETWEEN TRUNC(ADD_MONTHS(TO_DATE(20050228,'YYYYMMDD'),-12),'MON') and
    ADD_MONTHS(TO_DATE(20050228,'YYYYMMDD'),-12)
    In the same time while we use the same query for the leap year date:
    select * from day
    WHERE PERIOD_DATE BETWEEN TRUNC(ADD_MONTHS(TO_DATE(20080229,'YYYYMMDD'),-12),'MON')
    AND TO_DATE(20080229,'YYYYMMDD') + NUMTOYMINTERVAL(-1,'YEAR')
    I receive the following error - ORA-01839: date not valid for month specified.
    Problem:FLAG was incorrectly set to 'Y' for Feb 29 in 2004 during the report processing of Feb 28 data. Because of this, the extra day of Feb 29 2004 of Sales data was incorrectly being added to a report, thus overstating MTD sales of Feb 28 2004 by one full day. This appears to be caused by the fact that there were 28 days in Feb 2005 and 29 days in Feb 2004 becuase of the leap year. This will not cause problems until the next leap year.
    Can you please give me the resolution of the above.
    Thanks & Regards,
    Satheesh
    Message was edited by:
    user565141
    Message was edited by:
    user565141

    Hi Sateesh,
    I love your question, I have been writting quite often about this.
    ADD_MONTH is not the correct function to use, neither y2m interval.
    First, you need to define what is 2004-02-29 + 1 year. In most laws I found on the net (like majority and retirement policies), a leap-year baby will have his birthday on March 1st in non-leap years. If you have a contract, you must define this too.
    ex:
    update day set flag='Y'
      where period_date between
        trunc(ADD_MONTHS(:d,-12),'MON') and
        case to_char(:d,'MMDD')
          when '0228' then add_months(trunc(:d,'Y'),-12)+58
          else add_months(:d,-12) end;another approach would be
    where to_number(to_char(period_date,'YYYYMMDD')) between
      to_number(to_char(:d,'YYYYMM"00"'))-10000 and
      to_number(to_char(:d,'YYYYMMDD'))-10000;but if you have an index on period_date, the first solution may be more efficient
    Message was edited by:
    Laurent Schneider
    58 not 59
    Message was edited by:
    Laurent Schneider
    depending on how you define 29Feb -1Y, you could add
          when '0229' then add_months(trunc(:d,'Y'),-12)+59

  • Leap year in OBIEE

    Hi ,
    I have a problem about leap year in OBIEE, like 2012
    If I want to calculate the value on 2012/02/29 year on year,namely 2011/02/29,but there is no 29 in Feb/2 in 2011,only 28 days.
    so how can I do it?
    thank you!

    now the data is like follow:
    DAY QUANTITY QUANTITY_YEARONYEAR
    2011-02-28 1
    2011-03-01 2 5
    2012-02-28 3 1
    2012-02-29 4 2
    I think it should be
    DAY QUANTITY QUANTITY_YEARONYEAR
    2011-02-28 1
    2011-03-01 2 5
    2012-02-28 3 1
    2012-02-29 4

  • Leap Year, Month, determination program

    Hi - it's the learning student again :) Our new assignment is to create a program to determine leap year, month and day information. So basically you enter a year and the program says if it is a leap year. Then you enter a month and the program determines if that month is part of that leap year. And then you enter a day and determine if that day is part of that leap month that is part of that leap year. I have written a program to determine if it is a leap year and to determine that if the month is february it is a leap month, but not if the month is part of that leap year - so I am missing a step. And so it goes for the leap day - I have created the program to read that the 29th is a leap day but not exculsively to the month of february that falls in the leap year. Make sense? Here is my code so far:
    Here are details of the assignment:
    1.Prompt the user for a year using GUI dialogue window.
    a.Remember to give the user clear direction on input requirements.
    i.E.g. "Please enter month as integer 1-12:"
    2.Prompt the user for the month using GUI dialogue window.
    a.Remember to give the user clear direction on input requirements.
    b.** Please note: month must be input as a string, and then converted to an integer for the case statement below. This may require 2 case statements.
    3.Prompt the user for a day in the month.
    a.This must return a message to the user if the month doesn’t include that day.
    b.i.e. entering 30 in a February month should tell the user it is an invalid day and stop execution.
    4.Check to see if the year is a leap year.
    5.Check to see if the month is a leap month.
    6.Check to see if the day is a leap day.
    7.Display a user friendly back to the consumer indicating:
    a.Year entered & If it is a leap year
    b.Month entered & if it is a leap month.
    c.The number of days in the month (e.g. January has 31 days, whereas February has 28 unless it is a leap year.
    d.The day of the month entered & whether or not is a Leap day.
    e.Output can be in three different dialogue windows, or just 1 if desired.
    And here is my code - I am not sure what to do next. It is running and compiling without any errors right now but I know I am missing some steps. Any help or advice in what steps to take next would be appreciated!
    import javax.swing.JOptionPane;
    public class Leap_Year {
         public static void main (String[] args) {
         //Enter a year
         String enterYearString = JOptionPane.showInputDialog("Enter a year: ");
         //Convert year to an integer
         int enterYear = Integer.parseInt(enterYearString);
         // Check if year is a leap year
              boolean isLeapYear =
                        (enterYear % 4 == 0 && enterYear % 100 != 0) || (enterYear % 400 == 0);
         //Enter a month
              String enterMonthString = JOptionPane.showInputDialog("Enter a month as an integer, e.g. 1-12: ");
         //Convert month to an integer
         int enterMonth = Integer.parseInt(enterMonthString);     
         //Check if month is a leap year
                   boolean isLeapMonth =
                             (enterMonth == 2);
         //Enter a day
                   String enterDayString = JOptionPane.showInputDialog("Enter a Day as an integer, e.g. 1-31: ");
         //Convert day to an integer
              int enterDay = Integer.parseInt(enterDayString);     
         //Check if day is a leap day
                        boolean isLeapDay =
                                  (enterDay == 29);          
         //Display the result
         String output = "The year " + enterYear + " is a leap year is: " + isLeapYear +
                   "\nThe month " + enterMonth + " is a leap month is: " + isLeapMonth +
                   "\nThe day " + enterDay + " is a leap day is: " + isLeapDay;
         JOptionPane.showMessageDialog(null,output);
    }

    Ok - so I may have "over-coded" - since I am totally new to programming this might be sloppy. Apologies ahead of time. I have most of the stuff figured out. A couple of problems I am having. When I display my results as to whether or not the month is a leapy year is reads as:
    The year 2012 is a leap year is: true
    The month of February in the year 2012 is a leap month is: true
    How would I go about making it display something simple like:
    The year 2012 is a leap year.
    The month of February in the year 2012 is a leap year. OR
    The year 2013 is not a leap year.
    The month of January in the year 2013 is not a leap month.
    Additionally, I need to write a case statement that would return an error statement if someone tried to enter the wrong number of days in a month (example entering 31 days for the month of February).
    Here is my current code:
    import javax.swing.JOptionPane;
    public class LeapYear2 {
         public static void main (String[] args) {
         //Enter a year
         String enterYearString = JOptionPane.showInputDialog("Enter a year: ");
         //Convert year to an integer
         int enterYear = Integer.parseInt(enterYearString);
         // Check if year is a leap year
              boolean isLeapYear =
                        (enterYear % 4 == 0 && enterYear % 100 != 0) || (enterYear % 400 == 0);
         //Enter a month
              String enterMonthString = JOptionPane.showInputDialog("Enter a month as an integer, e.g. 1-12: ");
         //Convert month to an integer
         int enterMonth = Integer.parseInt(enterMonthString);     
         //Check if month is a leap year
                   boolean isLeapMonth =
                             (enterMonth == 2 && enterYear % 4 == 0 && enterYear % 100 != 0) || (enterYear % 400 == 0);          
         //Enter a day
                   String enterDayString = JOptionPane.showInputDialog("Enter a Day as an integer, e.g. 1-31: ");
         //Convert day to an integer
              int enterDay = Integer.parseInt(enterDayString);     
         //Check if day is a leap day
                        boolean isLeapDay =
                                  (enterDay == 29 && enterMonth == 2 && enterYear % 4 == 0 && enterYear % 100 != 0) || (enterYear % 400 == 0);          
         //Set number of days to a variable
                        int numDays;
         //Calculate the number of days in a month                    
                        if (enterMonth == 2)
                             if (isLeapMonth)
                             numDays=29;
                        else
                             numDays = 28;
                        else if (enterMonth == 1 || enterMonth == 3 || enterMonth == 5 || enterMonth == 7 || enterMonth == 8 || enterMonth == 10 || enterMonth == 12)
                             numDays = 31;
                             else
                                  numDays = 30;
         //Set the name of the month to a variable
                        String month = null;
         //Determine the number association to the name of the month
                        if (enterMonth == 1)
                             month = "January";
                        if (enterMonth == 2)
                             month = "February";
                        if (enterMonth == 3)
                             month = "March";
                        if (enterMonth == 4)
                             month = "April";
                        if (enterMonth == 5)
                             month = "May";
                        if (enterMonth == 6)
                             month = "June";
                        if (enterMonth == 7)
                             month = "July";
                        if (enterMonth == 8)
                             month = "August";
                        if (enterMonth == 9)
                             month = "September";
                        if (enterMonth == 10)
                             month = "October";
                        if (enterMonth == 11)
                             month = "November";
                        if (enterMonth == 12)
                             month = "December";
         //Display the result
         String output = "The year " + enterYear + " is a leap year is: " + isLeapYear + "." +
                   "\nThe month of " + month + " in the year " + enterYear + " is a leap month is: " + isLeapMonth + "." +
                   "\nThe day " + enterDay + " is a leap day is: " + isLeapDay + "." +
                   "\nThe month of " + month + " in the year " + enterYear +" has " + numDays +" days in it.";
         JOptionPane.showMessageDialog(null,output);
    }

Maybe you are looking for