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

reg:date conversion

Former Member
0 Likes
1,198

how to convert yyyymmdd to dd/mm/yy only using function module only without using offset

11 REPLIES 11
Read only

Former Member
0 Likes
1,171

Hi

DATA: e_date(10) type c VALUE '2/2/2006',

i_date(10).

CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'

EXPORTING

date_external = e_date

IMPORTING

date_internal = i_date

EXCEPTIONS

date_external_is_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.

WRITE : / 'CONVERT_DATE_TO_INTERNAL',

/ 'My Date:' , e_date ,

'Conv Date:', i_date.

skip 2.

CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'

EXPORTING

DATE_INTERNAL = sy-datum

IMPORTING

DATE_EXTERNAL = e_date

EXCEPTIONS

DATE_INTERNAL_IS_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.

WRITE : / 'CONVERT_DATE_TO_EXTERNAL',

/ 'My Date:' , sy-datum,

'Conv Date:', e_date.

Hope this helps

Regds

Seema

Read only

Former Member
0 Likes
1,171

Hi,

Only using offset.

data: lv_date(8) type c.

lv_date = sy-datum.

CONCATENATE lv_date6(2) '/' lv_date4(2) lv_date+2(2) INTO itab-date.

regards

Kannaiah

Read only

Former Member
0 Likes
1,171

Creatd a 10 Character variable (eq : W_date) , then use Write to statement.

Write SY-datum to W_date.

Hope this helps,

Regards,

Senthil N S

Read only

anversha_s
Active Contributor
0 Likes
1,171

hi,

just use this.

data:date_form type CHAR10.

call function 'HRGPBS_HESA_DATE_FORMAT'
exporting
P_DATE = sy-datum
importing
DATESTRING = date_form
exceptions
others = 1.


write : date_form.

Rgds

Anver

Read only

Former Member
0 Likes
1,171

Hi,

SimpleDateFormat fmtDatePlain = new SimpleDateFormat("dd/mm/yyyy");

String formattedDate = fmtDatePlain.format(yourdate)

the output is string

or

use write statement

write: sy_datum to v_datum dd/mm/yy.

Plz go through the following links .

I hope it will tell you all the things related to Date & time.

http://help.sap.com/saphelp_nw2004s/helpdata/en/96/aeb14000a6c84ee10000000a1550b0/frameset.htm

http://help.sap.com/saphelp_nw2004s/helpdata/en/96/aeb14000a6c84ee10000000a1550b0/frameset.htm

http://help.sap.com/saphelp_nw2004s/helpdata/en/42/c87909c84d136de10000000a1553f7/frameset.htm

regards

navjot

Read only

Former Member
0 Likes
1,171

hi Avrun

use function module <b> CONVERSION_EXIT_PDATE_OUTPUT </b>

sample code:


data:date_form(10).
 
call function 'CONVERSION_EXIT_PDATE_OUTPUT'
exporting
input = sy-datum
importing
output = date_form
exceptions
others = 1.
 
 
write : date_form.

hope this helps,

Sajan Joseph.

Read only

Former Member
0 Likes
1,171

Try using FM...

<b>CONVERT_DATE_TO_EXTERNAL</b>

Read only

former_member673464
Active Contributor
0 Likes
1,171

Hi,

You can use WRITE FORMATING.

Here the sample code:

DATA: BEGDA TYPE TEXT10,

ENDDA TYPE SY-DATUM.

WRITE SY-DATUM TO BEGDA DD/MM/YY .

WRITE SY-DATUM TO ENDDA DD/MM/YY .

And of course you can use other format, like:

... DD/MM/YY

... MM/DD/YY

... DD/MM/YYYY

... MM/DD/YYYY

... DDMMYY

... MMDDYY

... YYMMDD

Message was edited by:

veereshbabu ponnada

Read only

Former Member
0 Likes
1,171

Hi Varun,

Use function module CONVERT_DATE_TO_EXTERNAL. This will convert the date to the user specific format. So if your user specific format is mm/dd/yyyy, then this is all you need.

Hope this resolves your query.

Reward all the helpful answers.

Regards

Read only

Former Member
0 Likes
1,171

Hi Varun,

Have you checked Anversha's solution?? It was mentioned in your earlier thread also . pls check your answers before posting duplicate questions, Heres anvers solution

REPORT ZTEST.

DATA:DATE_FORM TYPE CHAR10.

CALL FUNCTION 'HRGPBS_HESA_DATE_FORMAT'
  EXPORTING
    P_DATE     = SY-DATUM
  IMPORTING
    DATESTRING = DATE_FORM
  EXCEPTIONS
    OTHERS     = 1.


WRITE : DATE_FORM.

Read only

Former Member
0 Likes
1,171

Hi,

Use the following function module

<b>SLS_MISC_CONVERT_TO_DATE</b>

Regards,

Sandhya