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

date conversion

Former Member
0 Likes
548

hi,

I have a field which has the date and time , i want to split this into standard date format only, pls help me!!

Thu Aug 31 19:22:00 PDT 2006

This is the format whcih we get from oracle, anybody who has done it before, pls let me know!!

points assured!!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
513

DATA : sapdate like sy-datum.

DATA : date type string value 'Thu Aug 31 19:22:00 PDT 2006'.

DATA : mm type char2.

if date+4(3) eq 'Jan'.

mm = '01'.

Elseif date+4(3) eq 'Feb'.

mm = '02'.

Elseif date+4(3) eq 'Mar'.

mm = '03'.

Elseif date+4(3) eq 'Apr'.

mm = '04'.

Elseif date+4(3) eq 'May'.

mm = '05'.

Elseif date+4(3) eq 'Jun'.

mm = '06'.

Elseif date+4(3) eq 'Jul'.

mm = '07'.

Elseif date+4(3) eq 'Aug'.

mm = '08'.

Elseif date+4(3) eq 'Sep'.

mm = '09'.

Elseif date+4(3) eq 'Oct'.

mm = '10'.

Elseif date+4(3) eq 'Nov'.

mm = '11'.

Elseif date+4(3) eq 'Dec'.

mm = '12'.

Endif.

concatenate date24(4) mm date8(2) into sapdate.

3 REPLIES 3
Read only

Former Member
0 Likes
513

Hi,

As this is a unique format from Oracle and I believe DATE will always be in this format, try following solution.

Thu Aug 31 19:22:00 PDT 2006

L_Month = date+4(3). Put a logic to get Month no from Month. Like

CASE MONTH.

WHEN 'JAN'.

L_MON = '01'.

WHEN 'FEB',

L_MON = '02'.

ENDCASE.

L_DAY = L_DATE+8(2).

L_Year = L_DATE+24(4).

L_TIME = L_DATE+11(8).

Now you have all the values so you can get date and time from the string.

Hope this helps.

ashish

Read only

Former Member
0 Likes
514

DATA : sapdate like sy-datum.

DATA : date type string value 'Thu Aug 31 19:22:00 PDT 2006'.

DATA : mm type char2.

if date+4(3) eq 'Jan'.

mm = '01'.

Elseif date+4(3) eq 'Feb'.

mm = '02'.

Elseif date+4(3) eq 'Mar'.

mm = '03'.

Elseif date+4(3) eq 'Apr'.

mm = '04'.

Elseif date+4(3) eq 'May'.

mm = '05'.

Elseif date+4(3) eq 'Jun'.

mm = '06'.

Elseif date+4(3) eq 'Jul'.

mm = '07'.

Elseif date+4(3) eq 'Aug'.

mm = '08'.

Elseif date+4(3) eq 'Sep'.

mm = '09'.

Elseif date+4(3) eq 'Oct'.

mm = '10'.

Elseif date+4(3) eq 'Nov'.

mm = '11'.

Elseif date+4(3) eq 'Dec'.

mm = '12'.

Endif.

concatenate date24(4) mm date8(2) into sapdate.

Read only

0 Likes
513

HI, thanks for the quick reply, but i get an error message saying that the offset conversion is too large. so pls let me know waht i can do!!