Application Development and Automation 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: 
Read only

Urgent: Date format conversion

Former Member
0 Likes
1,119

Hi

I need to convert the date from 08/31/2006 to 31-Aug-06 format.

Plz help me out. Useful answers will be rewarded. Thanks in advance.

Hi

I need to convert the date from 08/31/2006 to 31-Aug-06 format.

Plz help me out. Useful answers will be rewarded. Thanks in advance.

9 REPLIES 9
Read only

Former Member
0 Likes
1,095

split the date in to required blocks using "Split" command and try it out your requirement

Read only

Former Member
0 Likes
1,095

Hello,

Check the table :

T247

Check these fm's

Function Modules related to Date and Time Calculations

DATE_COMPUTE_DAY : Returns weekday for a date

DATE_GET_WEEK : Returns week for a date

DAY_ATTRIBUTES_GET : Returns attributes for a range of dates specified

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

Vasanth

Read only

Former Member
0 Likes
1,095

hi Vijay,

Use FM DAY_ATTRIBUTES_GET

Regards,

santosh

Read only

Former Member
0 Likes
1,095

Refer this

Currently my date is getting printed in format 05262005.

I want the output as 26 May, 2005.

I have tried using Set date mask option but it is not picking up in the output.

Code: 

This code yields as 12 march 2006. 

DATA: ZTEMP(9).  

CLEAR: ZTEMP, ZDD, ZMMM, ZYYYY.  

CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'  
EXPORTING  
INPUT = IS_DLV_DELNOTE-HD_GEN-CREA_DATE  
IMPORTING  
OUTPUT = ZTEMP.  

ZDD = ZTEMP+3(2).  
ZMMM = ZTEMP+0(3).  
ZYYYY = ZTEMP+5(4).

then u can c<b>oncatenate zdd zmmm zyyy INTO zdate seperated by '-'.</b>

http://www.sap-img.com/abap/abap-program-output-of-date-format.htm

Reward if this helps.

Read only

Former Member
0 Likes
1,095

hi Vijay,

TRY THIS CODE.

DATA : W_DATE TYPE CHAR10 VALUE '08/06/2007',

W_DATE1 TYPE D,

W_DATE2 TYPE CHAR12,

W_DATE3 TYPE CHAR15.

CALL FUNCTION 'RP_FORMATING_DATE'

EXPORTING

date_i = W_DATE

  • BIRTH_DATE = 'X'

IMPORTING

DATE_O = W_DATE1

EXCEPTIONS

DATE_INVALID = 1

OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'

EXPORTING

input = W_DATE1

IMPORTING

OUTPUT = W_DATE2

.

CONCATENATE W_DATE20(2) '-' W_DATE22(3) '-' W_DATE2+5(4) INTO W_DATE3.

WRITE : W_DATE3.

This will surely help u.

Regards,

Santosh.

Read only

Former Member
0 Likes
1,095

Hi,

Try FM <b>DAY_ATTRIBUTES_GET</b>

reward if useful.

Read only

Former Member
0 Likes
1,095

Get date month year in diff variables and concatnate it into one variable in which way do u need.

Read only

Former Member
0 Likes
1,095

hi Vijay,

i dint notice that u are asking for mm/dd/yyyy format in the input.

below is the code with a little change.

DATA : W_DATE TYPE CHAR10 VALUE '08/31/2006',

W_DATE1 TYPE D,

W_DATE2 TYPE CHAR12,

W_DATE3 TYPE CHAR15.

<b>concatenate w_date3(2) '/' w_date0(2) '/' w_date+6(4) into w_date.</b>

CALL FUNCTION 'RP_FORMATING_DATE'

EXPORTING

date_i = W_DATE

  • BIRTH_DATE = 'X'

IMPORTING

DATE_O = W_DATE1

EXCEPTIONS

DATE_INVALID = 1

OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'

EXPORTING

input = W_DATE1

IMPORTING

OUTPUT = W_DATE2

.

<b> CONCATENATE W_DATE20(2) '-' W_DATE22(3) '-' W_DATE2+7(2) INTO W_DATE3</b>.

WRITE : W_DATE3.

the input is 08/31/2006 and the out put is 31-AUG-06 this is what u want right.

Read only

Former Member
0 Likes
1,095

Hi,

DATA: gd_datetext TYPE string.

CASE sy-datum+4(2).

WHEN '01'.

gd_datetext = 'Jan'.

WHEN '02'.

gd_datetext = 'Feb'.

WHEN '03'.

gd_datetext = 'March'.

WHEN '04'.

gd_datetext = 'April'.

WHEN '05'.

gd_datetext = 'May'.

WHEN '06'.

gd_datetext = 'June'.

WHEN '07'.

gd_datetext = 'July'.

WHEN '08'.

gd_datetext = 'Aug'.

WHEN '09'.

gd_datetext = 'Sept'.

WHEN '10'.

gd_datetext = 'Oct'.

WHEN '11'.

gd_datetext = 'Nov'.

WHEN '12'.

gd_datetext = 'Dec'.

ENDCASE.

concatenate sy-datum(2)'-'gd_datetext'-'sy-datum+2(2) into

gd_datetext.

.

write:/ gd_datetext.

Regards,

Sruthi