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

Similar Messages

  • Adding days to a date

    Hi, i've been trying to add days to a date with no luck.
    I have two dates.
    Date date1= new Date();
    Date date2;
    I want date2 to equal x amount of days from date1.
    eg. date1 = 6/10/2004
    I want date2 to be 4 days from date1 so date2 would be 10/10/2004. i know this is very easy to do with the Calendar class but in my program it needs to be a Date because i parse Strings (dd/mm/yyyy) to Dates. It is not possible to parse Strings to Calendar date's right?
    So if anyone can help me add days to a Date object, it would be great!
    Thanks

    >
    testParse.java:33: 'void' type not allowed here
    System.out.println (testDate2.setTime(newTime));You are trying to print out the results of the void
    method, i.e. a void, not the object.
    d-unknown, if you look closely at the error message provided and the line it's complaining about, and use a little process of elimination, I think you'll find that there are only so many possibilities as to what possibly could be wrong.
    These compiler errors are not cryptic curses thrown up to stop people from getting work done, the counterspells to which are only known to those who have been through the rite of passage and had a coffee cup branded on their butts. The error messages are your friends. They tell you pretty precisely what went wrong and where if you take the time and effort to read an understand them.
    "'void' type not allowed here" -- Where have you ever seen the word void when programming Java? As the return type of a method, right? So, "'void' type" is probaby talking about the return type of some method.
    "not allowed here" -- well, it looks like you're doing something with a void where you can't have a void.
    There are only two method calls on that line--println and setTime. Both return void, so either one could be the problem. Either one might be being used where it's not allowed.
    But wait, what could possibly be wrong with where you're using println? It's just like every other println you've ever used.
    What about setTime? Well, println has several signatures. One takes object, and there's one for int, float, etc. So what you pass to println has to be one of those types. Is the return type of setTime an Object or int or long or anything? No, it's void. It's nothing. It has no value. println needs a value, but you're passing something that has no value. It would be like saying x=date2.setTime(...) It makes no sense, because a method with a void return type doesn't return any value.
    See, that wasn't so hard, was it? Yeah, it was wordy, but really if you start with "what could be void in this line and how could it be causing a problem," the thought process only has a few steps to get to the answer.

  • Adding days to a date causes it to be set back a year.

    Hello,
    I have the following problem on Oracle 10g. I run the following statment that adds 1 year to a date but, unless I format it, the date comes back with one year less than it should.
    SQL> select effective_date, (effective_date + interval '1' year(1)) as addyear, add_months(to_date(to_char(effective_date, 'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY HH24:MI:SS'), 12) as addyearformat
       from price_change
            where
            price_change_id = '794328'   ;
    EFFECTIVE_DATE  ADDYEAR         ADDYEARFORMAT
    28-SEP-09       28-SEP-08       28-SEP-10Has anyone else ever seen something like this?
    Effective_date is a date type and has data in the format 'MM/DD/YYYY HH24:MI:SS'. I think it is something with the format, maybe something to do with the time zone - not sure. If I just insert a value into the table with the format 'MM/DD/YYYY HH24:MI:SS' I don't have this problem. I don't know how the date could have been changed to cause this but I do know it goes through a time zone function before being inserted into this table though I don't know if that is causing the problem.
    Not sure if it matters but nls_database_parameters...
    PARAMETER VALUE
    NLS_DATE_FORMAT dd-mon-rr
    NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
    NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
    NLS_TIME_FORMAT HH.MI.SSXFF AM
    NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
    Thanks for any help in advance.
    Edited by: amcgator on Oct 15, 2010 11:52 AM

    Funny, but I think somehow your dates are BC:
    with price_change as (
                          select to_date('28-SEP-09 BC','dd-mon-yy bc') effective_date from dual
    select  effective_date,
            (effective_date + interval '1' year(1)) as addyear,
            add_months(to_date(to_char(effective_date, 'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY HH24:MI:SS'), 12) as addyearformat
      from  price_change
    EFFECTIVE ADDYEAR   ADDYEARFO
    28-SEP-09 28-SEP-08 28-SEP-10
    SQL> Issue:
    select  to_char(effective_date,'mm/dd/yyyy bc')
      from  price_change
      where price_change_id = '794328'
    /SY.

  • Leap Year Bug

    Hey all--
    I've noticed my Nano fails to display iCal events that occur (or start) on Feb 29 2008. After creating a new event on March 1 2008 and resyncing, however, the events on Feb 29 show up. To test this odd behavior, I then deleted the event on March 1 and resynced; the events on Feb 29 as well as some events in March all disappeared from my Nano, but remained in iCal. After adding an event to March 1 and resyncing, all events again displayed properly.
    Very unusual behavior... Has anyone else experienced this?

    Well I'm just an idiot. It's not the first time. Won't be the
    last.
    I saw the error in my code. Searched and found this leapyear
    bug post:
    http://www.feed-squirrel.com/index.cfm?evt=viewItem&ID=80015,
    and didn't do enough testing. The issue was that the code creates a
    date a year ahead, and there is no 2009-2-29 (which was the
    original issue before I posted broken test code).
    My apologies to Dan and the rest.

  • XQuery function : Adding day to current date

    I have a requirement to add 1 day to the current date during the Xquery transformation.
    Does anyone know if there is any xquery function that does that?
    From this link,
    http://download.oracle.com/docs/cd/E13214_01/wli/docs92/xref/xqdtopref.html#wp1162860
    it seems like there is a function, op: add-yearMonthDuration-to-dateTime, that serve this purpose, but I don't find it in OSB console IDE nor OEPE.

    You can use the below expression for adding 1 day (24 hrs) to a given current date:
    fn:current-dateTime() + xdt:dayTimeDuration("PT24H")
    Thanks,
    Patrick

  • Adding days to a date object

    I am retreiving a date field from the database.
    i am retrieving that with getDate() method on the result set object.
    that is am retrieving as java.sql.Date object.
    on that date object i have to add 30 days and store it back in the
    database as a date field in database.
    How should i go about handling this problem.
    suppose
    java.sql.Date newDate=rs.getDate(1);
    on this newDate how can i add 30 days and store it back to the database.
    Plz help me out guyz.
    Thanks.

    wud the setting to a particuale date means setting to
    the date i retrieved from the database.
    How to set for a particular date.We have setTime()
    method in Calendar.
    but that takes util.Date object.Then do i have to
    convert the sql.Date object into a util.Date object.A java.sql.Date IS-A java.util.Date.
    (There's no such thing as a sql.Date or a util.Date unless you have a different API than the rest of us.)

  • Need help in adding days to a date

    Hi,
    In rtf when if condition is true I have to add 7 days for a particular date.
    I am using logic like this <?xdofx:DATE+07?>
    but it is giving output like if :date is 27-FEB-08 then it is showing output like 2715
    I also checked like this
    case1:<?xdoxslt:ora_format_date_offset(DATE,'7', ‘+’)?>
    case2: <?xdofx:round((to_number(to_char(DUN_DATE,'JSSSSS'))+to_number(to_char(to_date('07','YYYY-MM-DD'),'JSSSSS'))) div 100000)?>
    Still not working.
    Please help me how to do this?
    Thanks in advance

    you should use these functions
    <?xdoxslt:ora_format_date_offset(xdoxslt:sysdate(),2,’+’)?>
    <?xdoxslt:ora_format_date_offset(yourdate, offset or days, ‘operator + - ’)?>
    i guess , something better will come in future , when the xsl 2.0, is being supported here in bip

  • Adding days to the date field

    Hi,
    I have a scenario as below.
    I have to add no. of days to the exixsting date field in the program. The statement is like this.
               <b>DATE1 = DATE + XDAYS.</b>
    Where <b>DATE</b> is in <b>DDMMYYYY</b> format. and XDAYS holds the number of days which will be retrieved from the standard table. And DATE1 should hold the result date.
    <b>eg:</b> Let <b>DATE</b> = <b>30.08.2007</b>
               <b>XDAYS</b> = <b>15</b>
    DATE1 = DATE + XDAYS.   =>   <b>DATE1 = 30.08.2007 + 15</b>.
    <b>DATE1 = 14.09.2007</b>
    Is there any easiest way to do this. or is there any function mdule  to do this operation.
    I hope you understood the question. Please let me know if I need to be more clear.
    Thanks in advance.
    -Pradeep.

    Hi,
    The date will be in internal format of 8 digits... Like 20070830..
    Directly add the number of days.. system will automatcally calculate
    w_new = w_old + 15 (20070830 + 15)
    w_new becomes 20070914
    and when you will write this : WRITE : w_new. It will show 14.09.2007 or depending on your settings for the date format. No need to call any fm for this..
    Thanks and Best Regards,
    Vikas Bittera.
    **Reward if useful**

  • Adding days in prompt date

    Hi Guys
    I need to create the filter like:-
    user select the date using the prompt on report while opening the report and i need to use the date entered by user which will be compared as
    date > user_Selected_dt +14 days..
    i have created the prompt and in report i can see the date selected by user using UserResponse () function but how to put same in filter.
    regards

    Just create a formula in Webi, let's say "Date Filter" =
    if date > user_Selected_dt +14 days then "filtered rows" else "Display All"
    No you can use the 'Date Filter" in interactive filter or table filters or controls.

  • 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);
    }

  • Date difference in years,month,days should consider Leap Year

    I would like to know how to compute the difference between two Date, and get the difference in years,months,days, PS. Should include New Year
    Eg Date1 : 01/01/2000
    Date2: 01/01/2005
    Diff: years=5, months=0 days=1 for a leap year is included'2004'

    I would like to know how to compute the difference
    between two Date, and get the difference in
    years,months,days, PS. Should include New Year
    Eg Date1 : 01/01/2000
    Date2: 01/01/2005
    Diff: years=5, months=0 days=1 for a leap year is
    included'2004'If any program I was using gave me that result, I would consider it a bug.

  • 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.

  • Bug or error when handling leap years with WDS/DS

    Hi all,
    I discovered a difference in outcome with Build and Debug (without screens) and Build and Debug with Web Determinations or Determinations Server when calculating days within leap years.
    I use the function DayDifferenceInclusive to calculate the amount of days in an insurance period.
    the amount of days of the insurance period = DayDifferenceInclusive(the start date of the insurance, the end date of the insurance)
    With the regression tester or Build and Debug (without screens) I get the following outcome for the following input:
    *93 = DayDifferenceInclusive(02-29-2008, 05-31-2008)*
    When we use Web Determinations or Determinations Server we get the value of *92* for the exact same input data when it should be 93.
    Is this a bug in the java code? How can we fix this or is there a work around for it?
    We're in the middle of System Integration Testing for a huge project so help is much appreciated!
    Best regards,
    Niels Roest

    Niels,
    thanks for that - and it looks like in the Netherlands daylight savings started on the 30th of March 2008, which as far as I know is the trigger for this error.
    I have reproduced the issue against 10.1 using the period 01 October 2010 to 30 October 2010, which contains the date that daylight saving started in Australia.
    As for ways to work around the issue, I can offer 3:
    * wait for 10.2 - it's in beta at the moment (though given your opening comments, this might not be an option for you)
    * set your server locale to one that doesn't have DST
    * work around the issue in rules:
    Firstly, the issue is that the shipping version fails because it doesn't take into account that one of the days is shorter than the standard 24 hours.
    The trick is to replace the DayDifference function with the HourDifference function and round to the nearest number of days.
    So given a rule that looks like:
    the result = DayDifference(date one, date two)
    it can be rewritten as:
    The result = round(HourDifference(date one at 00:00:00, date two at 00:00:00) / 24, 0)
    * the whole "at 00:00:00" is necessary because HourDifference works on datetimes, not dates.
    Sorry for the hassle.
    Regards
    Andrew

  • 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

  • How to get the difference of two dates in years,months and days

    Hi friends,
    how to get the difference of two dates in years,months and days
    for ex 2 years 3 months 13 days
    select (sysdate-date_Start) from per_periods_of_service
    thanks

    Something like this...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select to_date('17-nov-2006','dd-mon-yyyy') as c_start_date, to_date('21-jan-2008','dd-mon-yyyy') as c_end_date from dual union all
      2             select to_date('21-nov-2006','dd-mon-yyyy'), to_date('17-feb-2008','dd-mon-yyyy') from dual union all
      3             select to_date('21-jun-2006','dd-mon-yyyy'), to_date('17-jul-2008','dd-mon-yyyy') from dual
      4             )
      5  -- end of test data
      6  select c_start_date, c_end_date
      7        ,trunc(months_between(c_end_date, c_start_date) / 12) as yrs
      8        ,trunc(mod(months_between(c_end_date, c_start_date), 12)) as mnths
      9        ,trunc(c_end_date - add_months(c_start_date, trunc(months_between(c_end_date, c_start_date)))) as dys
    10* from t
    SQL> /
    C_START_D C_END_DAT        YRS      MNTHS        DYS
    17-NOV-06 21-JAN-08          1          2          4
    21-NOV-06 17-FEB-08          1          2         27
    21-JUN-06 17-JUL-08          2          0         26
    SQL>But, don't forget that different months have different numbers of days, and leap years can effect it too.

Maybe you are looking for

  • Using Parameter Form after migration from 6i to 11g

    Hello, I have a migration to do in order to use Reports 11g. But some of the RDF I have to convert use a parameter form at runtime for some of the parameters. How can I have the same functionality when calling these reports from my Forms application

  • How can I view my iPhoto album on my SmartTV?

    Hello All: I have a Samsung SmartTV and want to show my trip album (iPhoto) to my family via my TV. How can I do this? Right now, I do not see the AllShare icon my my Hub. I am hoping to do this wirelessly. When I bought this TV, I was under the impr

  • Problem in local host setting for webdynpro

    Hi, I configured the webdynpro and now when i click the webdynpro link the page not open but when i given the local host name and program name in the url path its work.but i want to set the automatically host name permenentaly in webdynpro design.

  • How to write files to the filesystem with portal/plsql

    Hi, is there a way to write files to the filesystem via Portal? Or can i call an external programm (perl, php) to do so, while portal writes further information to database? thank you for the help Ralf Schmitt

  • How to generate list of images used in project

    Is there a way I can generate a report or list of the images used in a homesite project? I want to remove unused images from the project directory. Thanks