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

Similar Messages

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

  • Add 1 day to the Month of February on leap year

    I know how to calculate leap year. The calculation is working great.
    However, I need to add a day to the month of February if a leap year is selected.
    Do you have any pointers on this?
    Thanks!

    Thanks!
    I got it
    if(leapYear){
    if (month==2)
    numDays = numDays +1;
    }

  • Combining yearly Photoshop Photography Program with monthly Complete Program?

    Hi all!
    I'm planing to subscribe to a discounted 1-year Photoshop Photography Program. However, I sometimes need other apps from Complete Program, like AI or AE, too (probably worth 3-4 months a year).
    For money saving reason. Is it possible to maintain a membership of Photoshop Photography Program while enrolling month-to-month Complete Program as needed along the way?
    Or I need 2 Adobe ID?
    Thanks!

    If you have the trial or any other perpetual license version you will need to uninstall that first. After that log out of CC, restart your machine and then log back into CC. LR should then be available to download.

  • How to calc the begining and end of every month (leap year)

    Hi all,
    I'm looking for a method that returns the begining and end of next month.
    example:
    today is 2005-10-04
    so the method suppose to return:
    2005-11-01
    2005-11-31 //as it ends on the 31
    I came up with the code below - but I don't like it as I can't get the end of month + it's not safe.
    any suggestions.
    Thanks
    Peter
    Calendar gcToday = Calendar.getInstance();
              int month = gcToday.get(Calendar.MONTH);
              int year  = gcToday.get(Calendar.YEAR);
              month+=2;
              if(month>12) //beacuase of month+=2;
                   year++;
                   month=1;
              String nextMonth;
              if (month<10)                         
                   nextMonth=year+"-0"+month+"-01";
              else
                   nextMonth=year+"-"+month+"-01"; 

    Look at using the methods getActualMaximum() and getActualMinimum() in the Calendar class. Basically what I would do is set the calendar to the 15th of the month (well, really anything between 1 and 28) and then add() one to the current month. The Calendar will roll over the dates as needed.

  • 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

  • Unable to generate the file report pdf on 29 february 2012 or during any leap year day...

    hii this is manab......
    sir/mam i have face the following error in 29 february 2012 for my overall company report .But i can easily get the
    report of another department on 29feb 2012....but when i try generate the overall report of my comapany then i find the errors
    REP-1401: 'cf_mc_prod_lyrformula': Fatal PL/SQL error occurred.
    ORA-01839: date not valid for month specified
    The following is the logfile.........
    ...........................................................................................log file................................................................................................................
    HPCL Custom Application: Version : UNKNOWN
    Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
    HPCCMDS module: HPC Modified CMD Report
    +---------------------------------------------------------------------------+
    Current system time is 04-SEP-2013 11:37:20
    +---------------------------------------------------------------------------+
    +-----------------------------
    | Starting concurrent program execution...
    +-----------------------------
    Arguments
    P_MILL='NPM'
    P_TRANSACTION_DATE='2012/02/29 00:00:00'
    Current NLS_LANG and NLS_NUMERIC_CHARACTERS Environment Variables are :
    American_America.US7ASCII
    REP-1401: 'cf_mc_prod_lyrformula': Fatal PL/SQL error occurred.
    ORA-01839: date not valid for month specified
    Report Builder: Release 6.0.8.24.0 - Production on Wed Sep 4 11:37:20 2013
    (c) Copyright 1999 Oracle Corporation.  All rights reserved.
    Enter Username:
    +---------------------------------------------------------------------------+
    Start of log messages from FND_FILE
    +---------------------------------------------------------------------------+
    +---------------------------------------------------------------------------+
    End of log messages from FND_FILE
    +---------------------------------------------------------------------------+
    Program exited with status 1
    Concurrent Manager encountered an error while running Oracle*Report for your concurrent request 11426643.
    Review your concurrent request log and/or report output file for more detailed information.
    +---------------------------------------------------------------------------+
    Executing request completion options...
    Finished executing request completion options.
    +---------------------------------------------------------------------------+
    Concurrent request completed
    Current system time is 04-SEP-2013 11:59:23
    +---------------------------------------------------------------------------+
    kindly give me solution .....i have e-business suite 11i
    internet explorer latest version...

    Hi,
    Please confirm whether this is a custom or standard report.
    If this is a custom report, then probably the respective issue has not been handled by exception handling.
    Also please refer note:
    How to check if version 11.5.10.2 is certified to Handle Leap Years (Doc ID 549937.1)
    Thanks &
    Best Regards,

  • Leap year debugging

    I'm having a hard time debugging this program,It's suppose to determine if a year is a leap year.
    import java.util.*;
    public class LeapYear
         static Scanner console = new Scanner(System.in);
         public static void main(String[] args)
         boolean isLeap = false;
         int year;
         String moreData;
         do
         System.out.print("Enter a year: ");
         year = console.nextInt();
         System.out.println();
         while(moreData.charAt(0) == 'y');
         System.out.print("Do you want to enter more data? y/n:");
         moreData = console.next();
    public static boolean isLeap(int year)
    if (year % 4 == 0 && year % 100 != 0)
    return true;
    if (year % 400 == 0)
    return true;
              System.out.println(year + " is " + (isLeap ? "" : "not ") + "a leap year.");
    }

    here what I have done so far, still got a couple of bugs in there.
    [import java.util.*;
    public class LeapYear
         static Scanner console = new Scanner(System.in);
         public static void main(String[] args)
         int year;
         System.out.print("Enter a year: ");
         console.nextInt();
         System.out.print("Do you want to enter more data? y/n:");
         console.nextLine();
         System.out.println(year + " is a leap year.");
         System.out.println(year + " is not a leap year.");
         public static int getYear()
              return year;
         public boolean isLeap(int year)
          if (year % 4 == 0 && year % 100 != 0)
             return true;
              if (year % 400 == 0)
                   return true;       
              else
                   return false; 
         public static int moreData (String response)
              if(response.charAt(0) == 'y')
                   return getYear;
    }/code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Leap Years

    Im kinda stuck .. will anyone help me 2 solve this problem.. >,<
    Background Information
    A year with 366 days is called a leap year. A year is a leap year if it is divisible by 4 (For example, 1996), except that it is not a leap year if it is divisible by 100 (For example, 1900); however, it is a leap year if it is divisible by 400 (for example, 2000); and there were no leap years before the introduction of the Gregorian Calendar on October 15, 1582.
    part 2 is
    Find the number of leap years elapsed between two leap years when February 29th occurred on the same day. For example if 29th of February 2000 is on a Tuesday, find the next leap year when 29th of February happens on Tuesday, display both years and the number of leap year in between.
    here is what i have done so far.
    import java.util.Scanner;
    public class leapyears
         public static void main(String[]args)
              int dayNumber,
              year,
              startLeapYear = 2000,
              endLeapYear = 2999;
              Scanner scan = new Scanner(System.in);
              System.out.println(" The first part of the program is to calculate and show the number of leap year\n"
                        + " between the year of 2000 and 2999.\n The second part is the number of leap years"
                        + "between two leap years when Febuary occurs on \n on the same day.\n");
              displayLeapYear( 2000, 2999);
              System.out.println("");
              int count = 0;
              do
                   System.out.println("Please enter the leap Year:");
                   year = scan.nextInt();
                   count ++;
              }while(!checkLeapYear(year));
              dayNumber = zeller(29,2,year);
              nextDay(year , dayNumber);
    public static void displayLeapYear(int startLeapYear, int endLeapYear)
    int count = 0;
    for( ; startLeapYear <= endLeapYear ; startLeapYear ++)
    if ( checkLeapYear(startLeapYear))
    System.out.print( startLeapYear+" ");
    startLeapYear ++;
    count++;
    System.out.println("\n There are "+ count+ " leap years");
    public static boolean checkLeapYear(int year)
    if( year % 4 == 0)
    if(year % 100 == 0 && year % 400 != 0)
    return false;
    return true;
    return false;
         public static String dayName(int dayNumber)
              switch(dayNumber)
              case 0:
                   return "Sunday";
              case 1:
                   return "Monday";
              case 2:
                   return "Tuesday";
              case 3:
                   return "Wednesday";
              case 4:
                   return "Thursday";
              case 5:
                   return "Friday";
              case 6:
                   return "Saturday";
              default :
                   return "Error";
         public static int zeller(int year, int month, int day)
              int dayNumber;
              int startMonth, startYear, leapFactor;
              day = 1;
              month = 2;
              startYear = 2000;
              if (month < 3)
                   startMonth = 0;
                   startYear = year -1;
              else
                   startMonth = (int)(0.4 * month + 2.3);
                   startYear = year;
              leapFactor = (startYear/4) - (startYear/100) + (startYear/400);
              dayNumber = ((365 * year + 31 * (month-1) + day + leapFactor - startMonth)-1) %7;
              return dayNumber;
         public static void nextDay(int year, int dayNumber)
              int startDay = 7, count = 0 ;
              do
                   year += 4;
              if(!checkLeapYear(year));
              else
                   startDay = zeller(29, 2, year);
                   System.out.print(year + " ");
                   count++;
              }while(startDay != dayNumber);
              System.out.println("The ");
         System.out.println("This day is "+ dayName(dayNumber));
    }

    http://java.sun.com/j2se/1.5.0/docs/api/java/util/GregorianCalendar.html#isLeapYear(int)
    ~

  • Calculating years,months & days

    Hi,
    i have to calculate the time duration in years,months and days between contract_start_date and contract_end_date
    eg: Contract_Start_Date = '17-nov-2006' and Contract_End_Date = '21-jan-2008'

    Rehman wrote:
    Hi,
    i have to calculate the time duration in years,months and days between contract_start_date and contract_end_date
    eg: Contract_Start_Date = '17-nov-2006' and Contract_End_Date = '21-jan-2008'It's not the simplest of things to work out.
    If you use the intervals it will, like any other calculation, struggle with the fact that there are different number of days in the month and leap years to take account of.
    Whilst it's simple enough to determine how many whole years have passed and how many months difference there is, the moment you start to take account of the days you become stuck because days in conjunction with months cause the day calculation to be a little more indeterminate...
    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         to_char(c_end_date,'YYYY')-to_char(c_start_date,'YYYY')
      8        -(case when to_date(to_char(c_end_date,'DD-MM')||'-1900','DD-MM-YYYY') <
      9                    to_date(to_char(c_start_date,'DD-MM')||'-1900','DD-MM-YYYY') then 1 else 0 end) as years_between
    10        ,case when to_date(to_char(c_end_date,'DD-MM')||'-1900','DD-MM-YYYY') <
    11                    to_date(to_char(c_start_date,'DD-MM')||'-1900','DD-MM-YYYY') then
    12                    12+(to_char(c_end_date,'MM')-to_char(c_start_date,'MM'))
    13         else (to_char(c_end_date,'MM')-to_char(c_start_date,'MM'))
    14         end -
    15        (case when to_date(to_char(c_end_date,'DD')||'-01-1900','DD-MM-YYYY') <
    16                   to_date(to_char(c_start_date,'DD')||'-01-1900','DD-MM-YYYY') then 1 else 0 end)
    17         as months_between
    18        ,case when to_date(to_char(c_end_date,'DD')||'-01-1900','DD-MM-YYYY') >
    19                   to_date(to_char(c_start_date,'DD')||'-01-1900','DD-MM-YYYY') then
    20              (to_char(c_end_date,'DD')-to_char(c_start_date,'DD'))
    21         else 31-(to_char(c_start_date,'DD')-to_char(c_end_date,'DD'))
    22         end as days_between_approx
    23        ,(c_end_date-c_start_date) year(4) to month as interval_yyyy_mm
    24* from t
    SQL> /
    C_START_D C_END_DAT YEARS_BETWEEN MONTHS_BETWEEN DAYS_BETWEEN_APPROX INTERVAL_YYYY_MM
    17-NOV-06 21-JAN-08             1              2                   4 +0001-02
    21-NOV-06 17-FEB-08             1              2                  27 +0001-03
    21-JUN-06 17-JUL-08             2              0                  27 +0002-01
    SQL>This example shows that a manual calculation can determine the number of years and months ok, but the days have to be approximated; and the interval answer isn't giving the same result for the months as the manual calculation because it can't take account of the days at the same time.

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

  • Release Date for Albums Year, MONTH DAY

    Why can't I enter the release date for albums (Year month and day)?   Itunes has a field for year but that's it.    I would have loved to be at the meeting where it was discussed.
    "Year, month and day? why the heck would any want that?"
    "Well a lot of us want to see our albums in chronological order and you can't do that with just the year, many albums come out every year"
    "Blah Blah Blah, music is just to dance to, no one cares about dates, besides it would four extra digit fields in each entry"
    But seriously, I would think that Itunes would aspire to be THE program for music lovers.
    Instead of being able to just enter the release dates I have had to come up with my own work around.  I put a the release date in the format yyyymmdd in fromt of each title and then sort by titles.
    Now all of my Beatle albums finally show up in chronological order by release date.   But why should I have to massage the data like this.   I can't imagine what goes on at Itunes planning  sessions.  I'm very unhappy about the loss of cover flow but that's another story.

    I'm glad to hear that I am not the only one who sees this as a problem.  And another Beatles fan too.
    This is so fundamental.  Every album has a release date and it's part of the data that is always associated with  that album.   Why did Apple look at the data available for an album and consciously decide to truncate it?
    What kind of music lover isn't aware of when albums are released?  I just don't get it.
    I like having the date yyyymmdd in front of each album.   It isn't pretty but it means the albums are chronological.   If you want, you could just put this in the sort field and leave the regular album title in the regular field.   Then the names would be right and they would sort correctly.   But again.  Why should we have to do all that? 
    Apple is busy constantly changing where the controls are on I tunes  rather than fixing something simple and important like this.
    Today I wanted to load some songs onto my ipod touch and it took me 10 minutes to figure out how to sync because the last itunes update got rid of the side bar.  
    How are you supposed to get comfortable using a product when they keep moving the controls around?   Just quit apple.   leave the controls where they are.  Add new controls if needed but stop moving them.  I know I'm ranting now but I am honestly angry and frustrated,

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

  • Selective deletion based on Calendar Year/Month in process chains

    Hi all,
    I have a requirement from the business wherein I have to delete the past months data before I load the same data into 6 infocubes using a process chain.
    I checked the forums to understand how selective deletion is used in a process chain and I have come to know that RSDRD_DELETE_FACTS program or DELETE_FACTS Tcode can be used to generata a G* program that performs the deletion.
    I am to integrate this generated program in my process chain. I have 0CALMONTH(Calendar Year/Month) as the time characteristic in all my infocubes and therefore the only time characteristic available for selective deletion.
    My problem is that I am unable to create a dynamic selection for the Calendar Year/Month such that it takes the previous month.To be exact I am unable to use the "D" option in the Selection Variable column for this characteristic.
    Please can somebody help me out with this.

    Hi,
    Use this ABAP program code in your Process Chain...
    Type Pools
        TYPE-POOLS: rsdrd, rsdq, rssg.
    Local Internal Tables
        DATA: lit_msg     TYPE rs_t_msg,
                    lit_sel     TYPE rsdrd_thx_sel.
    Local Work Area
        DATA : lwa_sel_kf1     TYPE rsdrd_sx_sel,
                   lwa_range_kf1  TYPE rsdrd_s_range.
    Local Constants
        CONSTANTS :    lc_i(1)      TYPE c  VALUE 'I',
                                 lc_x(1)      TYPE c  VALUE 'X',
                                 lc_eq(2)     TYPE c  VALUE 'EQ',
                                 lc_kf1(11)   TYPE c  VALUE '0CALMONTH'.
        CONSTANTS :   lc_cube      TYPE rsddatatarget VALUE 'Z_C21'.
    Delete Existing cube records
    Key Field 1 (CALMONTH)
          lwa_range_kf1-sign    = lc_i.
          lwa_range_kf1-option  = lc_eq.
          lwa_range_kf1-high    = space.
          lwa_range_kf1-keyfl   = lc_x.
          lwa_range_kf1-low     = <Value of CALMONTH>.
          APPEND lwa_range_kf1 TO lwa_sel_kf1-t_range.
          CLEAR  lwa_range_kf1.
           lwa_sel_kf1-iobjnm = lc_kf1.
          INSERT lwa_sel_kf1 INTO TABLE lit_sel.
          CLEAR : lwa_sel_kf1.
    Selective Deletion through FM
          CALL FUNCTION 'RSDRD_SEL_DELETION'
            EXPORTING
              i_datatarget      = lc_cube
              i_thx_sel         = lit_sel
              i_authority_check = space
              i_mode            = lc_c
              i_no_enqueue      = lc_x
            CHANGING
              c_t_msg           = lit_msg
            EXCEPTIONS
              x_message         = 1
              inherited_error   = 2
              invalid_type      = 3
              OTHERS            = 4.
          IF sy-subrc = 0.
            REFRESH : lit_sel[],
                      lit_msg[].
          ENDIF.
    Thanks,
    Saru

  • How to get date difference in terms of years,months and also days

    Tool : Eclipse
    Framework : JSF & Springs
    JRE : jdk1.5.0_06
    Iam using oracle 10G DB as back end.I have two date fields in a table.
    1)premium_paying_start_date
    2)premium_paying_end_date
    Iam getting these two dates from the database and storing these values within a entity.Now in the delegate layer,
    i have to get the premium_term i.e, the difference between the two dates(premium_paying_end_date-premium_paying_start_date).
    The difference should show the year,month and no of days difference.
    For example :
    premium_paying_start_date : 14-10-1984
    premium_paying_end_date : 01-03-2008
    Difference should be : 23 Y : 4 M : 15 D (Y = years, M = months , D= days)
    So please give me the solution for this.

    Difference should be : 23 Y : 4 M : 15 D (Y = years, M = months , D= days)
    So please give me the solution for this.How did you determine what the difference should be?
    ~

Maybe you are looking for