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

Country specific date format

Former Member
0 Likes
8,919

Hi,

Please help me as i require to display dates are per the country , for eg if it is US the date should be dd/mm/yyyy else for other countries like india it should be dd.mm.yyyy .

Regards

Abhishek

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,924

hai abishek,

try this one.

function group name--DATD

function group description--Date format

function module name---DATUMSAUFBEREITUNG

Country-specific date formatting for the current user.

Examples of output: MM/YY, MM/YYYY, DD.MM, M/D/YYYY, DD/MM/YYYY, WW/YY, WW/YYYY.

regards,

praba.

12 REPLIES 12
Read only

Former Member
0 Likes
4,924

Hi,

Did u try:CONVERT_DATE_TO_EXTERNAL

CONVERT_DATE_INPUT

CONVERT_DATE_TO_INTERNAL

CONVERT_DATE_TO_INTERN_FORMAT

To get the Format of the Date: SLS_MISC_GET_USER_DATE_FORMAT

Also chek this link:

and see Matthew Gifford's comments.

Hope it helps you

Regards,

Anjali

Read only

0 Likes
4,924

Hi Anjali,

Please read my query , i asked for country specific format dates.The FMs you have provided are for converting date formats.

Regards

Abhishek

Read only

Former Member
0 Likes
4,924

Hi Abhishek

use this function "TZ_SYSTEM_TO_LOCAL"

Thanks

Tharani

Read only

Former Member
0 Likes
4,924

go to T005 TABLE SEE FIELD DATFM

Read only

Former Member
0 Likes
4,925

hai abishek,

try this one.

function group name--DATD

function group description--Date format

function module name---DATUMSAUFBEREITUNG

Country-specific date formatting for the current user.

Examples of output: MM/YY, MM/YYYY, DD.MM, M/D/YYYY, DD/MM/YYYY, WW/YY, WW/YYYY.

regards,

praba.

Read only

0 Likes
4,924

Thanks Praba. It solved the problem.

Regards

Abhishek

Read only

0 Likes
4,924

Abhishek,

Pls reward points and close this thread.

Prabhu.

Read only

4,924

I know this is an old thread, but thought I would add my on comments:

    • This code example shows how to create a country specific date format.

    • Also see table T005 and field DATFM / Domain DATFM

DATA: external_date LIKE rvdat-extdatum,

country LIKE t005-land1,

internal_date LIKE syst-datum,

internal_period LIKE tprg-prgrs .

internal_date = sy-datum.

internal_period = 1.

country = 'DO'. "Dominican Republic

CALL FUNCTION 'PERIOD_AND_DATE_CONVERT_OUTPUT'

EXPORTING

country = country " Enter Country Code Here

internal_date = internal_date

internal_period = internal_period " Default this value to one

  • LANGUAGE = SYST-LANGU

  • I_PERIV = I_PERIV

  • I_WERKS = I_WERKS

  • I_MRPPP = I_MRPPP

IMPORTING

external_date = external_date " The date formated for the country will be in this field

  • EXTERNAL_PERIOD = EXTERNAL_PERIOD

  • EXTERNAL_PRINTTEXT = EXTERNAL_PRINTTEXT

  • EXCEPTIONS

  • DATE_INVALID = 1

  • PERIODE_INVALID = 2

.

Read only

0 Likes
4,924

Thankyou very much, this solved my issue

Read only

Former Member
0 Likes
4,924

Hi Abhishek,

In your program, have a logic to get the User's country. You shd be able to get this from the user master Tx: SU01.

Then use the statement as below, where <country> is the user's country.

SET COUNTRY <COUNTRY>.
write lv_date to lv_date_usr_format.

Now lv_date_usr_format will have the date in the country format set using the "SET CouNTRY" statement.

Pls reward points and close this thread, if this answers ur question.

Rgsd,

Prabhu.

Read only

Former Member
0 Likes
4,924

Hi,

Create a FM with IMPORT parameter as I_DAT,I_LAND

EXPORT parameter as E_DAT.

and write following code

DATA : V_DATE LIKE SY-DATUM,

V_DATFM LIKE T005-DATFM,

V_DAY(2) TYPE C,

V_MONTH(2) TYPE C,

V_YEAR(4) TYPE C,

V_LEN TYPE C.

V_LEN = STRLEN( I_DAT ).

IF V_LEN = 8.

V_YEAR = I_DAT+0(4).

V_MONTH = I_DAT+4(2).

V_DAY = I_DAT+6(2).

SELECT SINGLE DATFM INTO V_DATFM

FROM T005

WHERE LAND1 = I_LAND.

CASE V_DATFM.

WHEN 1.

CONCATENATE V_DAY V_MONTH V_YEAR INTO E_DAT. SEPARATED BY '.'.

WHEN 2.

CONCATENATE V_DAY V_MONTH V_YEAR INTO E_DAT. SEPARATED BY '/'.

WHEN 3.

CONCATENATE V_DAY V_MONTH V_YEAR INTO E_DAT. SEPARATED BY '-'.

WHEN 4.

CONCATENATE V_DAY V_MONTH V_YEAR INTO E_DAT. SEPARATED BY '.'.

WHEN 5.

CONCATENATE V_DAY V_MONTH V_YEAR INTO E_DAT. SEPARATED BY '/'.

WHEN 6.

CONCATENATE V_DAY V_MONTH V_YEAR INTO E_DAT. SEPARATED BY '-'.

ENDCASE.

ENDIF.

Use this FM in your program wherever you required.

Thanks,

Pramod

Read only

Former Member
0 Likes
4,924

I've found function module which can be used to convert date back to internal date.:

CALL FUNCTION 'PERIOD_AND_DATE_CONVERT_INPUT'
EXPORTING

  DIALOG_DATE_IS_IN_THE_PAST = ''
  EXTERNAL_DATE              = external_date
IMPORTING
  INTERNAL_DATE              = internal_date
EXCEPTIONS
  DATE_INVALID   = 1
  NO_DATA        = 2
  PERIOD_INVALID = 3
  OTHERS = 4.