Number of Days from a given Date

How can one calculate the number of days in a month from a given date?
Ex: If I pass 07/12/2008 it should return 31

But your example doesn't meet the OP request. The OP wanted the number of days in a month where the month is determined by a specified date (paraprhased).
DimaCit gave two credible solutions that met that requirement. Yours just counts the number of days between two apparently arbitrary dates.

Similar Messages

  • How to get the number of days between 2 given dates

    Hi all,
    How can I find the number of days between any 2 given dates.
    Thanks

    Hi
    Here's a dirty way:
    If you've got two Date objects in Java, call getTime() on each one (which gives you a value in milliseconds), then subtract the two millisecond values, and divide the result by the number of milliseconds in a day (24 * 60 * 60 * 1000). There's more `elegant' ways to do this, but this method only requires one line of Java.
    Best wishes
    Kevin

  • How to calculate a number of calendar days from a start date (e.g. 60 days from 3/10/2012)

    How to calculate a number of calendar days from a start date (e.g. 60 days from 3/10/2012)

    DT,
    If the starting date is in Column A, and you want to calculate what the date would be 60 days later, in Column B, write in Column B:
    =A+60
    Couldn't be much easier.
    Jerry

  • Customer Exit for Number of Days from 1 st Apr to last date of Month Enter

    Hello BI Experts,
    I have a requirement to count the number of days from 1 st April of current year to the last date of month entered.
    For example : The use will enter say July 2010 or 003.2010  (as Fiscal Year Variant is V3 ).
    Today is 14 July ...So we have to first find out the end date of the July month ie 31 st July
    Then go to 1 st April 2010.
    Now calculate the Number of days between 1 st April to 31 st July 2010.
    I consider I have to create two Customer Exit variable
    as below
    1 st customer exit Bex variable  say  ZLY_MTH  ( Last day of Month Entered)
      and i_step = 1
    2 nd Customer Exit BEx Formula variable say ZF_NUMDAYS ( Number of days between two dates)
    i_step =1 .
    Please provide me the logic for the above two.
    Thanks in Advance.
    Regards,
    Amol Kulkarni

    PSUDEO CODE:
    1. Initially LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE WHERE VNAM = 'ZMONTH'.
    2. Get the Month input using VAR_MONTH2 = LOC_VAR_RANGE-LOW+4(2)
    3. Now calculate Month+1: VAR_MONTH2 = VAR_MONTH2 + 1 (Refer **)
    4. Now calculate the Current Year: VAR_YEAR = LOC_VAR_RANGE-LOW+0(4).
    5. Get the 1st Day of the Month (VAR_MONTH2):  CONCATENATE '01' '/' VAR_MONTH2 '/' VAR_YEAR INTO L_S_RANGE-LOW.
    6. SUBRACT 1 (0DATE) from this DATE (This will give the logic for last day of the current month)
    Insert this code also for using the date conversions
            CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
              EXPORTING
                INPUT  = VAR_MONTH2
              IMPORTING
                OUTPUT = VAR_MONTH2.
    Pls. check out this logic. Guess it would solve your need.
    Thanks,
    Arun Bala

  • How to calculate number of days from a date field

    Dear BW Experts.
    I have a field 'Create Date' in the BEx query. Now we need to create a variable which should give the number of days from the date of running the query (sy-datum) to the Create Date.
    This will help the users to get records which are say, 30 days old (Sy-datum - create date = 30) or 10 days old etc.
    Could you suggest as to how to create this variable.
    Thanks,
    Sai

    Hi,
    Step 1: Create variable on "Create Date" with User entry processing type
    Step 2: Create a restricted KF for Sales & restrict it on "Create Date" to get "Sales on day"
    Step 3: Manipulate  the values of "Create Date" on which you could restrict  "Sales" again and again to get other values
    Step 4: Create one variable (ZPUTMNTH) for u201CMonth to Dateu201D with processing by u201CCustomer Exitu201D. This variable was created  on u201CDateu201D characteristics.
    Step 5 : Goto C-mod t-code and use EXIT_SAPLRRS0_001
    to calculate "month to date" user input is "Calday" Key Date
    WHEN 'ZPUTMNTH'.
    IF I_STEP = 2. "after the popup
    LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
    WHERE VNAM = 'ZPDATE'.
    CLEAR L_S_RANGE.
    L_S_RANGE-LOW = LOC_VAR_RANGE-LOW(6). "low value, e.g.YYYYMM (200606) part of key date (20060625)
    L_S_RANGE-LOW+6(2) = '01'. u201C low value e..g. YYYYMM01 (20060601)
    L_S_RANGE-HIGH = LOC_VAR_RANGE-LOW. "high value = input
    L_S_RANGE-SIGN = 'I'.
    L_S_RANGE-OPT = 'BT'.
    APPEND L_S_RANGE TO E_T_RANGE.
    EXIT.
    ENDLOOP.
    ENDIF.
    Assign if helps.....
    Regards,
    Suman

  • Find Previous Day From a Given Day

    Hey guys, I'm new here and I just recently started working with Java, I am trying to figure out how to find the previous day for the 1st day and month of a year_. I.E. if passed the date (1,1,2000) in the mm/dd/yyyy format then the output would be (12,31,1999). I have everything worked out except I have to figure out how to find the last day of the previous month. I am trying to write this all from scratch to better understand Java, so i do not want to use the Calendar class or anything involved with it.
    This is a handful of code that may not be formatted a bit sloppily, but if anyone has the time, I would greatly appreciate the help. (Also, I am aware that Java autmatically puts "this." if it is missing before a variable, I put mine in order to clearly see what's going on.) I made a test Class as well is anyone is interested in seeing it.
    Also, how come the Java formatting does not show in the post?
    * Date calculates the date and gives other information requested such as the birthday of someone, the
    * previous and next days, whether the date is valid or not, and whether the year is a leap year
    * @author Vlad Khmarsky
    * @version 1.1
    public class Date
    /** The month */
    int month = 00;
    /** The day */
    int day = 00;
    /** The year */
    int year = 0000;
    /** First month of the year */
    int firstMonth = 1;
    /** Last month of the year */
    int lastMonth = 12;
    /** Asks for the day, month, and year upon creting an instance of dates
    * @day asks for the day
    * @month asks for the month
    * @year asks for the year
    Date( int month_, int day_, int year_) {
    this.month = month_;
    this.day = day_;
    this.year = year_;
    /** Gets the month passed in initially
    * @return The month that is currently stored in the month field
    int getMonth() {
    return this.month;
    /** Gets the day passed in initially
    * @return The day that is currently stored in the month field
    int getDay() {
    return this.day;
    /** Gets the year passed in initially
    * @return The year that is currently stored in the month field
    int getYear() {
    return this.year;
    /** Gets the number of days in the given month
    * @return the number of days in the given month
    int getDaysInTheMonth() {
    return this.daysInTheMonth();
    /** Returns the date in Gregorian format
    * @return Returns the date in Gregorian format
    * Test Cases:
    * this.Dates(12, 10, 1989) = "12/10/1989"
    * this.Dates(54, 67, 9999) = "54/67/9999"
    * this.Dates(-1, -9, -900) = "-1/-9/-900"
    String toPrettyString() {
    return month + "/" + day + "/" + year;
    /** Checks whether the passed in date is valid or not
    * @return A true or false whether the date is valid
    * Test Cases:
    * this.Dates(12, 10, 1989) = true
    * this.Dates(54, 67, 9999) = false
    * this.Dates(-1, -9, -900) = false
    boolean isValid() {
    if (this.getDay() >= 0
    && this.getDay() <= 31
    && this.getMonth() >= 0
    && this.getMonth() <= 12) {
    return true;
    else {
    return false;
    /** Calculates the age of a person given the date
    * @return The age of the person
    * Test Cases:
    * this.Dates(12, 10, 1990), dateMarked.Dates(12, 10, 0) = 1990
    * this.Dates( 4, 25, 1000), dateMarked.Dates(12, 10, -990) = 1990
    * this.Dates( 1, 1, 2578), dateMarked.Dates(12, 10, 1989) = 589
    int calculateAge( Date birthday ) {
    return (this.getYear() - birthday.getYear());
    /** Do two dates represent the exact same day?
    * @param other The date to compare this Date against.
    * @return true if (and only if) this Date represents the same day as other.
    * (that is, the same year, month, day-of-month).
    * Test Cases:
    * this.Dates(12, 10, 1989), other.Dates(12, 10, 1989) = true
    * this.Dates(12, 10, 1989), other.Dates(11, 10, 1989) = false
    * this.Dates(12, 10, 1989), other.Dates(12, 9, 1989) = false
    * this.Dates(12, 10, 1989), other.Dates(12, 10, 1988) = false
    boolean isEqualTo( Date otherDate ) {
    if (this.getDay() == otherDate.getDay()
    && this.getMonth() == otherDate.getMonth()
    && this.getYear() == otherDate.getYear()) {
    return true;
    else {
    return false;
    /** Does one Date precede another?
    * @param other The date to compare this Date against.
    * @return true if (and only if) this Date comes before other.
    * this.Dates( 5, 5, 2000), other.Dates( 5, 6, 2000) = true
    * this.Dates( 5, 5, 2000), other.Dates( 6, 5, 2000) = true
    * this.Dates( 5, 5, 2000), other.Dates( 5, 5, 2001) = true
    * this.Dates( 5, 5, 2000), other.Dates( 5, 4, 2000) = false
    * this.Dates( 5, 5, 2000), other.Dates( 5, 5, 1999) = false
    * this.Dates( 5, 5, 2000), other.Dates( 4, 5, 2000) = false
    boolean isBefore( Date otherDate ) {
    if (this.getYear() <= otherDate.getYear()
    && this.getMonth() <= otherDate.getMonth()
    && this.getDay() < otherDate.getDay()) {
    return true;
    else if (this.getYear() <= otherDate.getYear()
    && this.getMonth() < otherDate.getMonth()) {
    return true;
    else if (this.getYear() < otherDate.getYear()) {
    return true;
    else {
    return false;
    /** Determines how many days there are in the month, given the instance's specified month and year
    * @Return returns the number of days in the month
    int daysInTheMonth () {
    if (this.isValid() == true) {
    if (this.getMonth() == 2) {
    if (this.isLeapYear() == true) {
    return 29;
    else {
    return 28;
    else if (this.getMonth() == 1
    || this.getMonth() == 3
    || this.getMonth() == 5
    || this.getMonth() == 7
    || this.getMonth() == 8
    || this.getMonth() == 10
    || this.getMonth() == 12) {
    return 31;
    else {
    return 30;
    else {
    return 0;
    /** Return the day after `this`. (`this` must be a valid date.)
    * @return the day after `this`. The result will be valid if `this` is valid.
    Date nextDay() {
    if (this.getDay() == this.getDaysInTheMonth() && this.getMonth() == 12) {
    return new Date(1, 1, this.getYear() + 1);
    else if (this.getDay() == this.getDaysInTheMonth()) {
    return new Date(this.getMonth() + 1, 1, this.getYear());
    else {
    return new Date(this.getMonth(), this.getDay() + 1, this.getYear());
    /** Return the day before `this`. (`this` must be a valid date.)
    * @return the day before `this`. The result will be valid if `this` is valid.
    Date previousDay() {
    if (this.getDay() == 1 && this.getMonth() == 1) {
    return new Date(12, this.getDaysInTheMonth(), this.getYear() - 1);
    //Need to fix the days in the previous month and previous month
    else if (this.getDay() == 1) {
    return new Date(this.getMonth() - 1, this.getDaysInTheMonth() - 1,
    this.getYear()); //need to fix the days in the previous month
    else {
    return new Date(this.getMonth() - 1, this.getDaysInTheMonth(), this.getYear());
    /** Returns a true or false depending on whether the year is a leap year or not
    * @return a true or false depending on whether the year is a leap year or not
    * Test Cases:
    * this.Dates( 5, 5, 2000) = true
    * this.Dates(12, 6, 2004) = true
    * this.Dates( 1, 1, 2001) = false
    * this.Dates( 7, 9, 2006) = false
    boolean isLeapYear () {
    if (this.getYear() % 400 == 0) {
    return true;
    else if (this.getYear() % 100 == 0) {
    return false;
    else if (this.getYear() % 4 ==0) {
    return true;
    else {
    return false;
    null
    Edited by: THE_Russian on Sep 28, 2007 4:35 PM

    Yeahhhh... that's exactly what I was trying not to do, I know that method, I don't want any associations with the Calendar class, thanks though
    Aw crap, you can't edit the original post? Sorry everyone for the unformatted code, here's the formatted version
    * Date calculates the date and gives other information requested such as the birthday of someone, the
    *  previous and next days, whether the date is valid or not, and whether the year is a leap year
    * @author Vlad Khmarsky
    * @version 1.1
    public class Date
    /** The month */
        int month = 00;
    /** The day */
        int day = 00;
    /** The year */
        int year = 0000;
    /** First month of the year */
        int firstMonthInYear = 1;
    /** Last month of the year */
        int lastMonthInYear = 12;
    /** First day of the month */
        int firstDayInMonth = 1;
    /** Asks for the day, month, and year upon creting an instance of dates
       * @day asks for the day
       * @month asks for the month
       * @year asks for the year
        Date( int month_, int day_, int year_) {
            this.month = month_;
            this.day = day_;
            this.year = year_;
    /** Gets the month passed in initially
       * @return The month that is currently stored in the month field
        int getMonth() {
            return this.month;
    /** Gets the day passed in initially
       * @return The day that is currently stored in the month field
        int getDay() {
            return this.day;
    /** Gets the year passed in initially
       * @return The year that is currently stored in the month field
        int getYear() {
            return this.year;
    /** Gets the number of days in the given month
       * @return the number of days in the given month
        int getDaysInTheMonth() {
            return this.daysInTheMonth();
    /** Returns the date in Gregorian format
       * @return Returns the date in Gregorian format
       * Test Cases:
       *    this.Dates(12, 10, 1989) = "12/10/1989"
       *    this.Dates(54, 67, 9999) = "54/67/9999"
       *    this.Dates(-1, -9, -900) = "-1/-9/-900"
        String toPrettyString() {
            return month + "/" + day + "/" + year;
    /** Checks whether the passed in date is valid or not
       * @return A true or false whether the date is valid
       * Test Cases:
       *    this.Dates(12, 10, 1989) = true
       *    this.Dates(54, 67, 9999) = false
       *    this.Dates(-1, -9, -900) = false
        boolean isValid() {
            if (this.getDay() >= 0
                && this.getDay() <= 31
                && this.getMonth() >= 0
                && this.getMonth() <= 12) {
                return true;
            else {
                return false;
    /** Calculates the age of a person given the date
       * @return The age of the person
       * Test Cases:
       *    this.Dates(12, 10, 1990), dateMarked.Dates(12, 10,    0) = 1990
       *    this.Dates( 4, 25, 1000), dateMarked.Dates(12, 10, -990) = 1990
       *    this.Dates( 1,  1, 2578), dateMarked.Dates(12, 10, 1989) =  589
        int calculateAge( Date birthday ) {
            return (this.getYear() - birthday.getYear());
    /** Do two dates represent the exact same day?
       * @param other The date to compare this Date against.
       * @return true if (and only if) this Date represents the same day as other.
       *  (that is, the same year, month, day-of-month).
       *  Test Cases:
       *    this.Dates(12, 10, 1989), other.Dates(12, 10, 1989) = true
       *    this.Dates(12, 10, 1989), other.Dates(11, 10, 1989) = false
       *    this.Dates(12, 10, 1989), other.Dates(12,  9, 1989) = false
       *    this.Dates(12, 10, 1989), other.Dates(12, 10, 1988) = false
        boolean isEqualTo( Date otherDate ) {
            if (this.getDay() == otherDate.getDay()
                && this.getMonth() == otherDate.getMonth()
                && this.getYear() == otherDate.getYear()) {
                return true;
            else {
                return false;
    /** Does one Date precede another?
       * @param other The date to compare this Date against.
       * @return true if (and only if) this Date comes before other.
       *    this.Dates( 5,  5, 2000), other.Dates( 5,  6, 2000) = true
       *    this.Dates( 5,  5, 2000), other.Dates( 6,  5, 2000) = true
       *    this.Dates( 5,  5, 2000), other.Dates( 5,  5, 2001) = true
       *    this.Dates( 5,  5, 2000), other.Dates( 5,  4, 2000) = false
       *    this.Dates( 5,  5, 2000), other.Dates( 5,  5, 1999) = false
       *    this.Dates( 5,  5, 2000), other.Dates( 4,  5, 2000) = false
        boolean isBefore( Date otherDate ) {
            if (this.getYear() <= otherDate.getYear()
                && this.getMonth() <= otherDate.getMonth()
                && this.getDay() < otherDate.getDay()) {
                return true;
            else if (this.getYear() <= otherDate.getYear()
                && this.getMonth() < otherDate.getMonth()) {
                return true;
            else if (this.getYear() < otherDate.getYear()) {
                return true;
            else {
                return false;
    /** Determines how many days there are in the month, given the instance's specified month and year
       * @Return returns the number of days in the month
        int daysInTheMonth () {
            if (this.isValid() == true) {
                if (this.getMonth() == 2) {
                    if (this.isLeapYear() == true) {
                        return 29;
                    else {
                        return 28;
                else if (this.getMonth() == 1
                         || this.getMonth() == 3
                         || this.getMonth() == 5
                         || this.getMonth() == 7
                         || this.getMonth() == 8
                         || this.getMonth() == 10
                         || this.getMonth() == 12) {
                    return 31;
                else {
                    return 30;
            else {
                return 0;
    /** Return the day after `this`.  (`this` must be a valid date.)
       * @return the day after `this`.  The result will be valid if `this` is valid.
      Date nextDay() {
          if (this.getDay() == this.getDaysInTheMonth() && this.getMonth() == 12) {
              return new Date(firstMonthInYear, firstDayInMonth, this.getYear() + 1);
          else if (this.getDay() == this.getDaysInTheMonth()) {
              return new Date(this.getMonth() + 1, firstDayInMonth, this.getYear());
          else {
              return new Date(this.getMonth(), this.getDay() + 1, this.getYear());
    /** Return the day before `this`.  (`this` must be a valid date.)
       * @return the day before `this`.  The result will be valid if `this` is valid.
      Date previousDay() {
          if (this.getDay() == 1 && this.getMonth() == 1) {
              return new Date(lastMonthInYear, this.getDaysInTheMonth(), this.getYear() - 1); //Need to fix the days in the previous month and previous month
          else if (this.getDay() == 1) {
              return new Date(this.getMonth() - 1, this.getDaysInTheMonth() - 1, this.getYear()); //need to fix the days in the previous month
          else {
              return new Date(this.getMonth() - 1, this.getDaysInTheMonth(), this.getYear());
    /** Returns a true or false depending on whether the year is a leap year or not
       * @return a true or false depending on whether the year is a leap year or not
       * Test Cases:
       *    this.Dates( 5,  5, 2000) = true
       *    this.Dates(12,  6, 2004) = true
       *    this.Dates( 1,  1, 2001) = false
       *    this.Dates( 7,  9, 2006) = false
        boolean isLeapYear () {
            if (this.getYear() % 400 == 0) {
                return true;
            else if (this.getYear() % 100 == 0) {
                return false;
            else if (this.getYear() % 4 ==0) {
                return true;
            else {
                return false;
    }null

  • To find the no of working days b/w given date

    Hi ABAP Experts,
             Here i have one requirement .
             table is tfacs
              in  this table i want to know the no of working days b/w  the given date. Here i have attached my code .pls go through it and do me needful.
    TABLES : tfacs,vbrk.
    DATA: BEGIN OF ty_tfacs OCCURS 0,
            ident TYPE tfacs-ident,
            jahr TYPE tfacs-jahr,
            mon01 TYPE tfacs-mon01,
            mon02 TYPE tfacs-mon02,
            mon03 TYPE tfacs-mon03,
            mon04 TYPE tfacs-mon04,
            mon05 TYPE tfacs-mon05,
            mon06 TYPE tfacs-mon06,
            mon07 TYPE tfacs-mon07,
            mon08 TYPE tfacs-mon08,
            mon09 TYPE tfacs-mon09,
            mon10 TYPE tfacs-mon10,
            mon11 TYPE tfacs-mon11,
            mon12 TYPE tfacs-mon12,
            basis TYPE tfacs-basis,
            fenum TYPE tfacs-fenum,
            wenum TYPE tfacs-wenum,
            load TYPE  tfacs-load,
            string1(31) TYPE c,
            string2(31) TYPE c,
            string3(31) TYPE c,
            string4(31) TYPE c,
            string5(31) TYPE c,
            string6(31) TYPE c,
            string7(31) TYPE c,
            string8(31) TYPE c,
            string9(31) TYPE c,
            string10(31) TYPE c,
            string11(31) TYPE c,
            string12(31) TYPE c,
            uk(31) TYPE c,
            total1 TYPE i,
            total2 TYPE i,
            total3 TYPE i,
            total4 TYPE i,
            total5 TYPE i,
            total6 TYPE i,
            total7 TYPE i,
            total8 TYPE i,
            total9 TYPE i,
            total10 TYPE i,
            total11 TYPE i,
            total12 TYPE i,
            END OF ty_tfacs.
    SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : s_jahr FOR tfacs-jahr MODIF ID b1.
    SELECT-OPTIONS : mon FOR tfacs-mon01  MODIF ID b1.
    SELECT-OPTIONS :  s_month FOR vbrk-erdat MODIF ID b2.
    SELECTION-SCREEN : END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME.
    PARAMETERS  r1 RADIOBUTTON GROUP c DEFAULT 'X' USER-COMMAND flag .
    PARAMETERS  r2 RADIOBUTTON GROUP c .
    SELECTION-SCREEN END OF BLOCK b.
             INITIALIZATION
    INITIALIZATION.
    AT SELECTION-SCREEN OUTPUT.
      IF r1 NE space.
        LOOP AT SCREEN.
          IF screen-group1 EQ 'B2'.
            screen-output = 1.
            screen-active = 0.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ELSE.
        LOOP AT SCREEN.
          IF screen-group1 EQ 'B1'.
            screen-output = 1.
            screen-active = 0.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.
              start - of - selection
    start-of-selection.
      IF r1 = 'X'.
        PERFORM get-data.
        PERFORM display-data.
      ENDIF.
    &      form  get-data
           text
      -->  p1        text
      <--  p2        text
    form get-data .
      DATA :  total1  TYPE i.
      SELECT * FROM tfacs INTO TABLE ty_tfacs
                                     WHERE ident EQ 'IN'
                                     AND   jahr IN s_jahr.
      LOOP AT  ty_tfacs WHERE ident = 'IN'.
        IF sy-subrc EQ 0.
          PERFORM get_string USING ty_tfacs-string1
                                   ty_tfacs-mon01
                                   ty_tfacs-total1.
          PERFORM get_string USING ty_tfacs-string2
                                    ty_tfacs-mon02
                                    ty_tfacs-total2.
          PERFORM get_string USING ty_tfacs-string3
                                   ty_tfacs-mon03
                                   ty_tfacs-total3.
          PERFORM get_string USING ty_tfacs-string4
                                         ty_tfacs-mon04
                                         ty_tfacs-total4.
          PERFORM get_string USING ty_tfacs-string5
                                         ty_tfacs-mon05
                                         ty_tfacs-total5.
          PERFORM get_string USING ty_tfacs-string6
                                         ty_tfacs-mon06
                                         ty_tfacs-total6.
          PERFORM get_string USING ty_tfacs-string7
                                         ty_tfacs-mon07
                                         ty_tfacs-total7.
          PERFORM get_string USING ty_tfacs-string8
                                         ty_tfacs-mon08
                                         ty_tfacs-total8.
          PERFORM get_string USING ty_tfacs-string9
                                         ty_tfacs-mon09
                                         ty_tfacs-total9.
          PERFORM get_string USING ty_tfacs-string10
                                         ty_tfacs-mon10
                                         ty_tfacs-total10.
          PERFORM get_string USING ty_tfacs-string11
                                         ty_tfacs-mon11
                                         ty_tfacs-total11.
          PERFORM get_string USING ty_tfacs-string12
                                         ty_tfacs-mon12
                                         ty_tfacs-total12.
        ENDIF.
        ty_tfacs-uk = ty_tfacs-total1 + ty_tfacs-total2
                      + ty_tfacs-total3 + ty_tfacs-total4
                      + ty_tfacs-total5 + ty_tfacs-total6
                      + ty_tfacs-total7 + ty_tfacs-total8
                      + ty_tfacs-total9 + ty_tfacs-total10
                      + ty_tfacs-total11 + ty_tfacs-total12.
        MODIFY  ty_tfacs TRANSPORTING  total1 total2 total3
                                       total4 total5 total6
                                       total7 total8 total9
                                       total10 total11 total12
                                       uk.
      ENDLOOP.
    PERFORM write1-data USING 'COU' 'YEAR' 'MONTH01'
                               'MONTH02' 'MONTH03' 'MONTH04'
                               'MONTH05' 'MONTH06' 'MONTH07'
                               'MONTH08' 'MONTH09' 'MONTH10'
                               'MONTH11' 'MONTH12' 'TOTAL WDAYS' .
    LOOP AT ty_tfacs.
       PERFORM write1-data USING ty_tfacs-ident ty_tfacs-jahr
                                 ty_tfacs-total1 ty_tfacs-total2
                                 ty_tfacs-total3 ty_tfacs-total4
                                 ty_tfacs-total5 ty_tfacs-total6
                                 ty_tfacs-total7 ty_tfacs-total8
                                 ty_tfacs-total9 ty_tfacs-total10
                                 ty_tfacs-total11 ty_tfacs-total12
                                 ty_tfacs-uk.
    ENDLOOP.
    ENDFORM.                    " get-data
    TOP-OF-PAGE.
      FORMAT COLOR 5 ON.
      WRITE :/10 'COUNTRY',
              20 'YEARS',
              35 'MON01',
              45 'MON02',
              55 'MON03',
              65 'MON04',
              75 'MON05',
              85 'MON06',
              95 'MON07',
              105 'MON08',
              115 'MON09',
              125 'MON10',
              135 'MON11',
              145 'MON12',
              170 'total wdays'.
      FORMAT COLOR OFF.
      WRITE :/ SY-ULINE.
    *&      Form  display-data
          text
    -->  p1        text
    <--  p2        text
    FORM display-data .
      LOOP AT ty_tfacs.
        WRITE :/10 ty_tfacs-ident,
                20 ty_tfacs-jahr,
                30 ty_tfacs-total1,
                40 ty_tfacs-total2,
                50 ty_tfacs-total3,
                60 ty_tfacs-total4,
                70 ty_tfacs-total5,
                80 ty_tfacs-total6,
                90 ty_tfacs-total7,
               100 ty_tfacs-total8,
               110 ty_tfacs-total9,
               120 ty_tfacs-total10,
               130 ty_tfacs-total11,
               140 ty_tfacs-total12,
               150 ty_tfacs-uk.
      ENDLOOP.
    ENDFORM.                    " display-data
    *&      form  get_string
          text
         -->p_0250   text
         -->p_0251   text
         -->p_0252   text
    form get_string  using    p_0250   " month
                              p_0251   " string
                              p_0252.  " total
    p_0250 = p_0251.  " move month to string
    TRANSLATE p_0250 USING '0 ' . " translate
    CONDENSE p_0250  NO-GAPS.     " condense
    p_0252 = STRLEN( p_0250 ).    " pass length of string to total
    ENDFORM.                    " get_string
    ***&      Form  write1-data
          text
         -->P_0306   text
         -->P_0307   text
         -->P_0308   text
         -->P_0309   text
         -->P_0310   text
         -->P_0311   text
         -->P_0312   text
         -->P_0313   text
         -->P_0314   text
         -->P_0315   text
         -->P_0316   text
         -->P_0317   text
         -->P_0318   text
         -->P_0319   text
         -->P_0320   text
    *form write1-data  using    p_0306
                              p_0307
                              p_0308
                              p_0309
                              p_0310
                              p_0311
                              p_0312
                              p_0313
                              p_0314
                              p_0315
                              p_0316
                              p_0317
                              p_0318
                              p_0319
                              p_0320.
    *WRITE :/ p_0306,
            p_0307,
            p_0308 left-justified,
            p_0309 left-justified,
            p_0310 left-justified,
            p_0311 left-justified,
            p_0312 left-justified,
            p_0313 left-justified,
            p_0314 left-justified,
            p_0315 left-justified,
            p_0316 left-justified,
            p_0317 left-justified,
            p_0318 left-justified,
            p_0319 left-justified,
            p_0320 left-justified.
    *ENDFORM. " write1-data
    from this report what i am getting is year and its 12 months but my requirement is i will give date using select options and i should get the total no of  working days in b/w this date.

    Use the following code to find no of working days b/w given date. Use the correct factory_calendar_id in the function module. L_DAYS will display the required result:
    PARAMETERS: p_date1 TYPE sydatum,
               p_date2 TYPE sydatum.
    DATA: date1        LIKE scal-date,
         date2        LIKE scal-date,
         correction   LIKE scal-indicator,
         calendar     LIKE scal-fcalid,
         factorydate1  LIKE scal-facdate,
         workday1      LIKE scal-indicator,
         factorydate2  LIKE scal-facdate,
         workday2      LIKE scal-indicator,
         l_days TYPE scal-facdate.
    CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
      EXPORTING
        date                       = p_date1
        correct_option             = '+'
        factory_calendar_id        = 'US'
      IMPORTING
        date                       = date1
        factorydate                = factorydate1
        workingday_indicator       = workday1
      EXCEPTIONS
        correct_option_invalid     = 1
        date_after_range           = 2
        date_before_range          = 3
        date_invalid               = 4
        factory_calendar_not_found = 5.
    IF sy-subrc = 0.
      CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
        EXPORTING
          date                       = p_date2
          correct_option             = '+'
          factory_calendar_id        = 'US'
        IMPORTING
          date                       = date2
          factorydate                = factorydate2
          workingday_indicator       = workday2
        EXCEPTIONS
          correct_option_invalid     = 1
          date_after_range           = 2
          date_before_range          = 3
          date_invalid               = 4
          factory_calendar_not_found = 5.
      IF sy-subrc = 0.
        l_days = factorydate2 - factorydate1.
        WRITE: / l_days.
      ENDIF.
    ENDIF.

  • Need to add number of days to users end date.

    Hi,
    I have a code where we are adding number of days(30) to current date and then updating user's end date in IDM DB.
    Now we have a requirement where we need to add number of days(30) to existing end date of user instead of adding to current date.
    *public String incrementDate(int daysToAdd)
         // Start date
         log.info("NotifyLastDayOfService::incrementDate(): Enter");
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
         Calendar c = Calendar.getInstance();
         c.add(Calendar.DATE, daysToAdd); // number of days to add
         String newDate = sdf.format(c.getTime());
         log.info("NotifyLastDayOfService::incrementDate(): Exit");
         return newDate;
    Have any body implemented this scenario?
    Please suggest.
    Thanks,
    Kalpana.

    Hi Nayan,
    Here is the code:
    System.out.println("----inside increment date method-----");     
              HashMap<String, String> hm = new HashMap<String, String>();
              HashMap<String,Date> modifyMap=new HashMap<String,Date>();
              SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
              tcResultSet usrList = null;
         String enddate = null;
         hm.put("Users.Key",usrKey );
         try {
         usrList = this.usrIntf.findUsers(hm);
         usrList.goToRow(0);
         Date endDate =usrList.getDate("Users.End Date");
         System.out.println("-----users end date-----"+endDate);
         String userEndDate=sdf.format(endDate);
         System.out.println("-----String value of users end date-----"+userEndDate);
         Calendar cal=null;
         System.out.println("-----Calender date-----"+cal);
         cal.setTime(endDate);
         System.out.println("-----end date-----"+endDate);
    cal.add(Calendar.DATE, Integer.parseInt(daysToAdd)); // number of days to add
    Date newEnddate = cal.getTime();
    System.out.println("-----new end date-----"+newEnddate);
    //usrList.setEndDate(Edate);
    modifyMap.put(userEndDate,newEnddate);
    usrIntf.updateUser(usrList, modifyMap);
    System.out.println("updated user's end date in OIM DB");
    //System.out.println("-----updated user's end date in OIM DB-----");
    logger.info("NotifyLastDayOfService::incrementDate(): Exit");
         System.out.println("-----new date-----");
         } catch (tcAPIException e) {
         logger.error("Error in finding end date for user" + e);
         } catch (tcColumnNotFoundException e) {
         logger.error("Error in finding end date for user" + e);
    In th log file, I can see that the code is not executing this line:
    cal.setTime(endDate);
    end date is of type Date and stores users end date from DB. Please help in resolving this issue.
    Thakns,
    Kalpana.

  • How do you work out the number of days difference between two dates?

    I'm running Crystal v12.
    We use a date field in our SQL database that we use to store the client's year end date.
    As the year end date (date and month) doesn't change for a client, the year end date field in all of our reports is set to just show the DD/MM part. Over the years as new clients are set up we just enter the date and month - the year part is irrelevant although as in all date fields the year is automatically entered.
    Doing it this way means that we don't have to adjust the year end year part each year. We just use the DD/MM part.
    I need to create a formula that works out the number of days there have been (i.e. the difference) from the current date to the year end date. It MUST EXCLUDE the year however.
    For example:
    Year End Date = 30/04/03
    Current Date = 25/05/10
    Days Difference (EXCLUDING year) = 25
    Days Difference (including year) = 2582
    Year End Date = 31/03/09
    Current Date = 25/05/09
    Days Difference (EXCLUDING year) = 55
    Days Difference (including year) = 420
    If you include the year part then working out day difference is simply a case of creating a formula that subtracts the year end date from the current date (CurrentDate - {tblClient.YearEnd}.
    HOWEVER I need to exclude the year part.
    Can anyone tell me the formula or best way to do this?
    Thanks in advance.
    Edited by: BadBoy House on May 25, 2010 3:15 PM
    Edited by: BadBoy House on May 25, 2010 3:15 PM

    Hi
    You can try this
    datevar e := date(year(currentdate),month({tblClient.YearEnd}),day({tblClient.YearEnd}));
    numbervar num_days := datediff("d",currentdate,e)
    Create a datevar called e that uses the original month and day numbers for {tblClient.YearEnd} but uses the year of the current date
    Then just datediff on e to get the number of days between the two dates
    I hope i understand your problem and that this helps
    Best regards
    Patrick

  • How to know the day of a given date?

    Hello Experts,
    Is there any function module that can give the day of a given date? For example, If
    I put in 10/30/2007, it will give me Tuesday. Hope you can help me guys.Thank you and take care!

    Hi
    Yes, DATE_COMPUTE_DAY
    Sample code:
      clear: hold_day_of_week.
      CALL FUNCTION 'DATE_COMPUTE_DAY'
           EXPORTING
                DATE = workdate
           IMPORTING
                DAY  = day_of_week_num
           EXCEPTIONS
                OTHERS  = 8.
      CASE day_of_week_num.
        WHEN 1.
          hold_day_of_week = 'Monday'.
        WHEN 2.
          hold_day_of_week = 'Tuesday'.
        WHEN 3.
          hold_day_of_week = 'Wednesday'.
        WHEN 4.
          hold_day_of_week = 'Thursday'.
        WHEN 5.
          hold_day_of_week = 'Friday'.
        WHEN 6.
          hold_day_of_week = 'Saturday'.
        WHEN 7.
          hold_day_of_week = 'Sunday'.
        WHEN OTHERS.
          hold_day_of_week = 'invalid'.
      ENDCASE.
    or 
    You can use  DATE_COMPUTE_DAY to get the day number of the week (for example, today gives 5)
    then use WEEKDAY_GET which returns an itab with seven entries (one for each day of the week.)
    You enter in this itab and get the field langt to get the day name.
    code @ http://www.sap-img.com/abap/fm-to-get-the-day-for-a-particular-date.htm
    Pls reawrd points

  • FM which gives the date if we add 'x' number of days to the current date.

    Hi all,
    can you plz tell me the FM which will give me the exact date if i add some ' X ' number of days to the present date.
    in detail -->my inputs would be    1)DATE
                                                    2)no of days
    i need--> the exact date which comes after those days get added to the given date.
    PLZ HELP ASAP.
    Rgds,
    REDDY.

    Hi,
    You can use FM RP_CALC_DATE_IN_INTERVAL.
    data: wa_date  like sy-datum.
    *Add 21 days to current date.
    call function 'RP_CALC_DATE_IN_INTERVAL'
             exporting
                  date      = sy-datum
                  days      = 21
                  months    = 0
                  signum    = '+'
                  years     = 0
             importing
                  calc_date = wa_date.
    write: / wa_date.
    Regards,
    Ferry Lianto

  • How do I calculate days from two different dates?

    Hi all,
    How do I calculate days from two different dates?
    my requirement is to pass the number of days to target field from two dates.
    Current date :  14/04/2010
    Standard date: 01/01/1957 is the standard = day 0
    Is it possible in graphical mapping with out  udf?
    Plz help me on this I have donu2019t have much knowledge on JAVA.
    Thanks

    Hi Yadav,
    Probably this is not the correct forum for XI / PI .
    You can post the same to...
    Process Integration (PI) & SOA Middleware
    Hope this helps.
    Regards
    Raj

  • How do I calculate days from two different dates in XI/PI?

    Hi all,
    How do I calculate days from two different dates in XI/PI?
    my requirement is to pass the number of days to target field from two dates.
    Current date : 14/04/2010
    Standard date: 01/01/1957 is the standard = day 0
    Is it possible in graphical mapping with out udf?
    Plz help me on this I have donu2019t have much knowledge on JAVA.
    Thanks

    Hi Yadav,
    Probably this is not the correct forum for XI / PI .
    You can post the same to...
    Process Integration (PI) & SOA Middleware
    Hope this helps.
    Regards
    Raj

  • Find the 'DAY' for a given 'DATE'

    Hi Folks,
    I need a help regarding finding the day for a given date.
    My requirement is that..,
             If I enter a date using 'parameters', it should write the 'day' for the corresponding date.
    To be more specific.....,
    if I enter date as ' 07/15/2008 ' it should return me  the day as 'Tuesday'.
    Regards,
    Naveen G

    HI,
    FM LIST WITH RESPECT TO DAY, WEEK, AND MONTH.
    CALCULATE_DATE : Calculates the future date based on the input .
    DATE_TO_DAY : Returns the Day for the entered date.
    DATE_COMPUTE_DAY : Returns weekday for a date
    DATE_GET_WEEK : Returns week for a date
    RP_CALC_DATE_IN_INTERVAL : Add days / months to a date
    MONTHS_BETWEEN_TWO_DATES : To get the number of months between the two dates.
    END_OF_MONTH_DETERMINE_2 : Determines the End of a Month.
    HR_HK_DIFF_BT_2_DATES : Find the difference between two dates in years, months and days.
    FIMA_DAYS_AND_MONTHS_AND_YEARS : Find the difference between two dates in years, months and days.
    MONTH_NAMES_GET : Get the names of the month
    WEEK_GET_FIRST_DAY : Get the first day of the week
    HRGPBS_HESA_DATE_FORMAT : Format the date in dd/mm/yyyy format
    SD_CALC_DURATION_FROM_DATETIME : Find the difference between two date/time and report the difference in hours
    L_MC_TIME_DIFFERENCE : Find the time difference between two date/time
    HR_99S_INTERVAL_BETWEEN_DATES : Difference between two dates in days, weeks, months
    LAST_DAY_OF_MONTHS : Returns the last day of the month
    DATE_CHECK_PLAUSIBILITY :Check for the invalid date.
    Reward points if useful,
    siri

  • Calculating 60 days from last run date and sum a total for those 60 days

    I need to calculate 60 days from last run date (I will create prompts), then take that number to sum a total of items.
    Can someone be of assistance.

    Hi,
    You can create a calculation to calculate 60 days before your run date. e.g. if rundate is your date item then the calculation will be:
    rundate-60
    Rod West

Maybe you are looking for

  • Dsatsource /ODS/Cube for Open PR and Open PO"

    Dear Experts I want to build a report in which I need to show "Open PR and Open PO" but I could not locate these fields in the BW CUBE / ODS / DATASOURCES. Can anybody tell me where I can find these fields.......... Dinesh Sharma

  • Navigation menu indicator triangle problem

    Hi all, the navigation menu of my site looks correct in layout mode: It still looks correct in preview mode (notice the triangles' position): BUT when I go on to Safari, either by previewing it or uploading to my server, the triangles interfere with

  • Keypad problem

    Dear All, I have problem with my keypad,some characters do not work for example: Number:7,9 and alphabet M,N.even the key pushing for a long time still not appear . Any one can help me? Best regards T.S.Pasaribu  T.S.Pasaribu

  • Problem to open folders

    I have a Mac OS X intel (10.6.8) and always ran on the desktop a folder with several subfolders. Suddenly this folder, although that appear on the desktop, I can not open it, what could have happened and what I can do to recover the files in those fo

  • Elements Tags Accessible from Windows

    I have a large photo collection with many, many different tags for sorting and collating, all within Elements 8.   My problem is that I often need to access my photos from several different systems, not all of which have Elements installed.  I realiz