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 format

Former Member
0 Likes
4,160

hi all,

i have an issue of the date format at the selection screen,

i have actually PARAMETERS: p_date TYPE sy-datum DEFAULT sy-datum. the default is sy-datum but the requirement is to display date in Format - MM/DD/YYYY. by date mask we can maximum get Format - DD/MM/YYYY BUT this not exactly they wanted.please help on this issue. i need to get this date format at selection screen default value.

7 REPLIES 7
Read only

Former Member
0 Likes
3,687

Use CONCATENATE and SPLIT command and convert sy-datum to your desired format.

Do this in INITIALIZATION event and pass it to parameter p_date.

Read only

Former Member
0 Likes
3,687

Verma,

under below event

INITIALIZATION.

DATA : v_date like sy-datum.

concatenate sy-datum4(2) '/' sy-datum6(2) '/'

sy-datum+0(4) into v_date.

p_date = v_date.

if length is not sufficient make P_date and v_date of length

10

Don't forget to reward if useful.

Read only

Former Member
0 Likes
3,687

Hi,

thats all dependent on user profile settings.For me iam getting what you wanted .because by default that option is active.You can also do the samething by going to the menupath

In the selection screen you have menu path

SYSTEM->USERPROFILE>OWNDATA-->DEFAULTS tab -->HERE YOU GIVE CHOICE WHAT EVER FORMAT YOU WANTED.

aND REEXECUTE THE PROGRAM ONCE YOU CHOOSE.

oTHERWISE SOMETIMES YOU HAVE TO RESTART SAP.

it will definitely work for your issue. If any issue please revert back.

Regds

Sivaparvathi

Please reward points if helpful..

Read only

Former Member
0 Likes
3,687

Hi Abhinash,

Kindly check if the below logic will help you out.

(This is sample code written to get the date in required format)

TYPES: BEGIN OF ty_date,

yyyy TYPE char4,

mm TYPE char2,

dd TYPE char2,

END OF ty_date.

DATA: l_date TYPE sydatum,

ls_date TYPE ty_date,

l_req_date_format TYPE char10.

l_date = sy-datum.

ls_date = l_date.

CONCATENATE ls_date-mm '/' ls_date-dd '/' ls_date-yyyy INTO l_req_date_format.

WRITE / l_req_date_format.

Regards,

Farheen

Read only

Former Member
0 Likes
3,687

Hai,

use command SET COUNTRY 'US' in START-OF-SELECTION..

This may help you.

Sample Code:

REPORT zaer_test1 .

DATA: RECEIVER_COUNTRY LIKE T005X-LAND VALUE 'US'.

PARAMETERS: DT TYPE SY-DATUM.

INITIALIZATION.

START-OF-SELECTION.

SET COUNTRY RECEIVER_COUNTRY.

END-OF-SELECTION.

write: /10 DT.

Read only

Former Member
0 Likes
3,687

Hi, this may help you.

This coding will help you to display the date in the format 'mm/dd/yyyy'.

DECLARE @DT DATETIME

SET @DT = '2003-01-22 10:31 PM'

SELECT '0' + CAST(MONTH(@DT) AS CHAR(1)) + '/' + CAST(DAY(@DT) AS

CHAR(2)) + '/' + CAST(YEAR(@DT) AS CHAR(4))

With Regards

Madhu

Read only

Former Member
0 Likes
3,687

hi