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