Skip to Content
author's profile photo Former Member
Former Member

Calculate the days in the year

Hi Gurus,

My requirement is, If U select the date counting the days in the year.

which FM is used the calulate the days in the year (365 days)

example: if I will execute 2 feb 2008 I want display 033

because in January month 31 days are there and adding the february month 2 days it will be totally 33 days in the year.

if I Execute 15 march 2008

it will be display 075 = 31(January)29(february)15(march)

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2008 at 09:31 AM

    hi,

    you can directly write this logic in your code itself.

    check the following code.

    DATA: dt1 TYPE sy-datum,
          dt2 TYPE sy-datum,
          count TYPE i.
    
    dt2 = '20070303'.
    
    CONCATENATE dt2(4) '0101' INTO dt1.
    count = dt2 - dt1 + 1.       "count must be of type integer
    
    WRITE count.
    

    try using different years (leap and non leap). "count" variable will give you the correct result for all cases.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2008 at 09:21 AM

    HI,

    Use the FM and pass the Start date of the year and the Date of Execution you will get the result.

    FIMA_DAYS_BETWEEN_TWO_DATES_2

    Reagrds

    Sumit Agarwal

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2008 at 09:25 AM

    Use FM SD_DATETIME_DIFFERENCE.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2008 at 09:25 AM

    DAYS_BETWEEN_TWO_DATES

    hi try this

    it will work

    sure

    with regards

    s.janagar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2008 at 09:26 AM

    Hi,

    Check the following:

    HR_SGPBS_ADD_TIME_TO_DATE

    HR_MX_DAYS_PER_YEAR

    FIMA_DAYS_BETWEEN_TWO_DATES

    Hope this will be helpful.

    Regards,

    P.S.Chitra

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 22, 2008 at 09:35 AM

    Hi,

    Use this FM

    HR_NL_PS_CALENDERDAYS_360

    ********************************************************************

    Data : Num type INT4.

    Data : Begdate type sy-datum, " Always make it to 1 Jan

    Enddate type sy-datum. " Date for which you want to count

    Begdate = '01.01.2008'.

    CALL FUNCTION 'HR_NL_PS_CALENDERDAYS_360'

    EXPORTING

    BEGINDATUM = Begdate

    EINDDATUM = Enddate

    IMPORTING

    KALENDERDAGEN = Num.

    Write :/ Num.

    Edited by: Bala Krishna on Sep 22, 2008 3:05 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2008 at 10:03 AM

    Hi sreedhar,

    The followinf FMs will be useful.

    Give the start date as year starting date.say example 01.01.2008 and end date of choice required.

    FIMA_DAYS_AND_MONTHS_AND_YEARS

    HR_SGPBS_YRS_MTHS_DAYS

    FIMA_DAYS_BETWEEN_TWO_DATES

    Can find the related FM by as follows,

    In SE37 - type (star) days(star) as name of FM and press F4.

    Gives u a pop up with list of FMs.

    check & use the required one.

    Regards,

    Salini.

    Edited by: satya salini on Sep 22, 2008 12:04 PM

    Edited by: satya salini on Sep 22, 2008 12:06 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2008 at 10:21 AM

    Hi,

    simple use this:

    data: dat1 like sy-datum.

    data: dat2 like sy-datum.

    data: days type i.

    *

    dat1 = '20080615'.

    *

    dat2 = dat1.

    dat2+4(4) = '0101'.

    days = dat1 - dat2.

    *

    write: / dat1, dat2, days.

    *

    Regards, Dieter

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.