Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

FM - convert dates into day of year

colin_cheong
Contributor
0 Kudos

Hi SAP guru,

Is there a SAP FM that allows me to input a date,

eg

20.06.2008

and return me the day of the year,

eg

254

out of 365 days.

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Use this function module HR_CALC_YEAR_MONTH_DAY, and give the starting and ending date of the year to get the no of days (but it will give based on YEARS, MONTHS, DAYS).

Edited by: Ravi Kumar on Jun 20, 2008 3:26 PM

13 REPLIES 13

Former Member
0 Kudos

Hi,

Use this function module HR_CALC_YEAR_MONTH_DAY, and give the starting and ending date of the year to get the no of days (but it will give based on YEARS, MONTHS, DAYS).

Edited by: Ravi Kumar on Jun 20, 2008 3:26 PM

0 Kudos

Hi,

I cannot find the FM you mentioned.

I am on rel4.7 and I am not having HR module.

Former Member
0 Kudos

use FM

HR_HK_DIFF_BT_2_DATES

pass date1 (the day U want to enter)

date2 = first day of the year(get year from date1)

output_format = 02.

U'll get the days in DAYS ...

0 Kudos

Thanks for the prompt reply.

However, you have not clearly understand my problem.

I need to find out the day of the year, not the difference

Former Member
0 Kudos

hi

try this FM this will solve ur problem

FIMA_DAYS_AND_MONTHS_AND_YEARS

SD_CALC_DURATION_FROM_DATETIME

HR_99S_INTERVAL_BETWEEN_DATES

<REMOVED BY MODERATOR>

Cheers

Snehi

Edited by: Alvaro Tejada Galindo on Jun 20, 2008 9:59 AM

Former Member
0 Kudos

hiiii

i have logic for getting total number of days..like below.it will help you to get days..

PARAMETERS:
          p_date TYPE sy-datum.

SELECTION-SCREEN END  OF BLOCK b1 .

DATA:
      w_date   TYPE sy-datum,
      w_second TYPE d,
      w_result TYPE i.

                
AT SELECTION-SCREEN OUTPUT .

    p_date = sy-datum.
    w_date = p_date - 1.
    p_date = w_date.


START-OF-SELECTION.

  w_second = p_date.
  w_second+6(2) = '01'.
  w_result =  w_date - w_second.

  WRITE: / 'Number Of Days Is:',w_result.

<REMOVED BY MODERATOR>

thx

twinkal

Edited by: Alvaro Tejada Galindo on Jun 20, 2008 10:00 AM

Former Member
0 Kudos

data: days type i .

CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'

EXPORTING

BEGDA = '20080101'

ENDDA = sy-datum

TAB_MODE = ' '

IMPORTING

DAYS = days .

write:/ 'no of days is' , days .

0 Kudos

Thanks for the prompt reply.

However, this is not what I am looking for.

I need to know the day of year.

Former Member
0 Kudos

Use the FM--- OIUH_PWTOJULIANDT.

Pass the date only in the format YYYY-MM-DD.

The above FM contains 3 parameters and all are mandatory:

Result will be stored in the RDATE parameter. The first four letters contains the Year and next letters contain the day of the year.

<REMOVED BY MODERATOR>

Regards,

Kiran Bobbala

Edited by: Alvaro Tejada Galindo on Jun 20, 2008 10:00 AM

Former Member
0 Kudos

Colin,

You can use this FM "HR_AUPBS_MONTH_DA" to get return the year of day. But u need to give the start date and end date.

Regards,

Suresh Kumar.

0 Kudos

Thanks for the prompt reply.

However, this is not what I need.

I had only 1 date. I need to convert it to day of year.

nikhil_chitre
Active Participant
0 Kudos

Hi,

Use Function Module

FI_PSO_DAYS_MONTHS_YEARS_GET.

Give start date

And To Date.

This would calculate the number of days.

Regards,

Nikhil

colin_cheong
Contributor
0 Kudos

Thanks for all the suggestion.

I decided to use FUNCTION 'BKK_ADD_WORKINGDAY'.

This function allows me to get the last date before input date.