cancel
Showing results for 
Search instead for 
Did you mean: 

how to change the date format of system

ankitjain10
Explorer
0 Kudos

hi

i want to write the system date in the format of dd.mm.yyyy.

rgds

ankit

Accepted Solutions (1)

Accepted Solutions (1)

athavanraja
Active Contributor
0 Kudos

Welcome to SDN.

Since you asked this question in BSP forum , i assume you wanted this in a BSP page.

write the following statement in the page layout

<%= page->to_string( value = sy-datum ) %>

this will print the date according to the user date format (set in usr02-datfm field)

if you want say only two digits of the year you can use the following

<%= page->to_string( value = sy-datum format = if_bsp_page~CO_FORMAT_SHORT ) %>

for more on this check out BSP application IT00 page basic_write.htm

Regards

Raja

ankitjain10
Explorer
0 Kudos

is their any other method for the same

athavanraja
Active Contributor
0 Kudos

other method is to manually handle this.

note: sy-datum will always be in the format of yyyymmdd

for dd-mm-yyyy do the following.

<%

data: mydate(10) .

concatenate sy-datum6(2) '-' sy-datum4(2) '-' sy-datum+0(4) into mydate .

%>

<%= mydate %>

Regards

Raja

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Nothing wrong with Raja's answer, but if you are on Netweaver04s you can avoid the old concatenate have yourself some Regular Expressions fun:

[code]DATA: idate(10).

idate = sy-datum.

replace regex `(\d\d\d\d)(\d\d)(\d+)` in idate with `$3.$2.$1`.[/code]

Answers (1)

Answers (1)

SergioFerrari
Active Contributor
0 Kudos

If you use model binding system will format the date based on the user profile (SU01).

Sergio