Skip to Content
Author's profile photo Kumar Saurabh

Why Date format is YYYYDDMM

As a beginner in ABAP we have always curiosity to know the reason for something

unusual . Once such curiosity is to know why date format is YYYYMMDD . We

have always used date as DD.MM.YYYY format. So for what reason SAP system

uses date as YYYYMMDD format . This phenomenon will be explained below with

proper example.

Suppose we uses date in format DD.MM.YYYY , so for this we will use data format

as C(10) .

Data lv_date type c(10) value ’10.12.2014’ .

Data lv_date1 type c(10) value ’20.09.2014’ .

Suppose above two date are stored in some internal table and we are required to sort

the internal table by date in ascending order . Guess ! what will be the result .

Since 10.12.2014 GT 20.09.2014 .

However if we store this in char (10). It will be treated as character, so sorting will be

done character by character and as we know 20092014 GT 10122014, so we will get

Result

20.09.2014 GT 10.12.2014 which is wrong !!!!

So if we store date in YYYYMMDD format which is Numeric(8) , Sorting result will

always come proper .

In above example .

Lv_date = 20141210

Lv_date1 = 20140920

So lv_date1 GT lv_date i.e.

10.12.2014 GT 20.09.2014

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Sharath Yaralkattimath
      Sharath Yaralkattimath

      Hi Saurabh,

      Nice post.

      So if we store date in YYYYDDMM format which is Numeric(8) , Sorting result will

      A small correction, in above statement the format should be YYYYMMDD?

      Author's profile photo Raymond Giuseppi
      Raymond Giuseppi

      During Y2K projects the bells tolled fo the coding of multiply date in DMY format by 1000.01 (DDMMYY × 10000.01 DDMMYYDDMM.YY so in a field of length 6 without decimal, only YYMMDD) to sort them...


      Also, not every country use MDY, there are also DMY (and more exotic too) and separator can be '-', '/' or '.'


      Regards,

      Raymond

      Author's profile photo Former Member
      Former Member

      Hi Saurabh,

      Thank you for sharing this.good information.