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)

10|10000 characters needed characters exceeded

### Related questions

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.

10|10000 characters needed characters exceeded
• 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

10|10000 characters needed characters exceeded
• Former Member
Posted on Sep 22, 2008 at 09:25 AM

Use FM SD_DATETIME_DIFFERENCE.

10|10000 characters needed characters exceeded
• 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

10|10000 characters needed characters exceeded
• Former Member
Posted on Sep 22, 2008 at 09:26 AM

Hi,

Check the following:

HR_MX_DAYS_PER_YEAR

FIMA_DAYS_BETWEEN_TWO_DATES

Regards,

P.S.Chitra

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

10|10000 characters needed characters exceeded
• 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

10|10000 characters needed characters exceeded
• 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