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

how to convert the Date format

Former Member
0 Likes
1,303

hi,

In one of my layout the requirement is...................date is printing in the format

dd.mm.yyyy........but it should be printed in dd month yyyy(for example.....it should be like 24 Aug 2007).Is there any function module to do so......?or else how can I do this....?

Thanks for the solution given

hi,

In one of my layout the requirement is...................date is printing in the format

dd.mm.yyyy........but it should be printed in dd month yyyy(for example.....it should be like 24 Aug 2007).Is there any function module to do so......?or else how can I do this....?

Thanks for the solution given

8 REPLIES 8
Read only

kiran_k8
Active Contributor
0 Likes
1,256

Deepthi,

Use this Fn Module:-

CONVERSION_EXIT_SDATE_OUTPUT-changes the date format as 31 Aug 2007 if given as 31/08/2007.

K.Kiran.

Read only

Former Member
0 Likes
1,256

hi,

goto utilities and there is one option for you to set date format, currency format........

if helpful reward some points.

with regards,

Suresh Aluri.

Read only

Former Member
0 Likes
1,256

Hi,

Check the following link:

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

Regards,

Bhaskar

Read only

Former Member
0 Likes
1,256

hi .

i dont no about FM but u can do this in code .

ex :

data : dt(20),

date type sy-datum value sy-datum.

if sy-datum+4(2) = '01'

concatenate sy-datun6(2) 'jan' sy-datum0(4) into dt.

endif.

regards

prajwal

Read only

Former Member
0 Likes
1,256

Try this FM,

CONVERSION_EXIT_IDATE_OUTPUT

Regards,

Savitha

Read only

Former Member
0 Likes
1,256

Hi,

Try this...

DATA :

i_date LIKE sy-datum,

lv_date TYPE d,

lv_day(2) TYPE n,

lv_month(2) TYPE n,

lv_year(4) TYPE n,

lv_mnt LIKE t247-ktx.

CLEAR: lv_date,

lv_day,

lv_year,

lv_month,

lv_mnt,

wv_final.

i_date = wv_low.

lv_date = i_date.

lv_year = lv_date(4).

lv_month = lv_date+4(2).

lv_day = lv_date+6(2).

CALL FUNCTION 'ISP_GET_MONTH_NAME'

EXPORTING

date = lv_date

language = wc_e

month_number = 00

IMPORTING

shorttext = lv_mnt

EXCEPTIONS

calendar_id = 1

date_error = 2

not_found = 3

wrong_input = 4

OTHERS = 5.

CONCATENATE lv_day lv_mnt lv_year INTO wv_final SEPARATED BY wc_l.

Read only

Former Member
0 Likes
1,256

Hi Deepthi,

<b>Different methods of Converting Date in ABAP</b>

Timestamp to Date

Example

&----


& Form convert_timestamp_to_date&----


*form convert_timestamp_to_date using par_timestamp par_time_zone changing par_date par_time. data: lc_timestamp type timestamp. clear: par_date, par_time, lc_timestamp. lc_timestamp = par_timestamp. CONVERT TIME STAMP lc_timestamp TIME ZONE par_time_zone INTO DATE par_date TIME par_time.endform.

" convert_timestamp_to_date

<b>and</b>

Date to Timestamp

Example

&----


& Form convert_date_to_timestamp&----


*form convert_date_to_timestamp using par_date par_time par_time_zone changing par_timestamp. clear par_timestamp. CONVERT DATE par_date TIME par_time INTO TIME STAMP par_timestamp TIME ZONE par_time_zone.endform.

" convert_date_to_timestamp

<b>and</b>

Calculate begining of previous to end of previous month

ldate = sy-datum.

ldate+6(2) = '01'.

ldate = ldate - 1.

fdate = ldate.

fdate+6(2) = '01'.

move: fdate to date-low,

ldate to date-high.

append date.

-


I need to convert date from dd.mm.yyyy to yyyymmdd at runtime.

I do not know if there is any function module or not but try following code.

/*************************************************

/**************************************************

data mydate like sy-datum.

data: year(4) type c,

month(2) type c,

date(2) type c.

year = mydate(4).

month = mydate+4(2).

date = mydate+6(2).

write: / year no-gap, month no-gap, date.

/*************************************************

/**************************************************

Pratik Shah

I am facing one problem with date. Can you suggest me how to save date with some format . for ex: can I save '2004.12.01' in the table with the same format. Right now I am getting output '2...1.2004' but I need output '2004.12.01'.

Date will save in any like yyyymmdd.

Just for display only you can do whatever ever you want.

write:/ gv_date edit mask 'YYYY.MM.DD'.

<b>Date and Time Calculations</b>

http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb334a358411d1829f0000e829fbfe/content.htm

http://www.sap-img.com/fu008.htm

Regards,

Kumar.

Read only

Former Member
0 Likes
1,256

Hi,

split your date into three variable lv_date, lv_month and lv_year.

Now use FM "MONTH_NAMES_GET", you will get the months names in the tables parameter "MONTH_NAMES".

Read this table with key MNR = lv_month into lv_monthname.

At last concatenate all the three variable lv_data lv_monthname and lv_year separated by '/'.

ELSE you can use the FM <b>"CONVERSION_EXIT_SDATE_OUTPUT"</b>

Pass you date with no separations Eg; 20071213.

and output will be 13.DEc.2007

rewards if useful,

regards,

nazeer