‎2010 Aug 09 6:32 PM
Hi,
I have a field with length 10 and another field with data type DATS.
Now, I need to compare these two fields.
DATA : v1 type char10,
v2 type sy-datum.
v1 = 01.12.2010.
v2 = 01.01.2010
now I need compare the above two fields.But, they are of different data types.
So, could you please help me out, how to do this. Is there any possiblty to change character field into DATE type.
Thanks,
Sandeep
Moderator message: basic date conversion question, please search for information before asking.
locked by: Thomas Zloch on Aug 10, 2010 10:31 AM
‎2010 Aug 10 3:10 AM
Hi,
It is better to compere variables with same data type.
Convert your character data to date, for this you can use concatenate.
Data v3 type sy-datum.
Concatenate v16(4) v13(2) v1+0(2) into v3.
Please make sure this is YYYYMMDD.
Regards,
‎2010 Aug 10 7:49 AM
Hi,
Use the function module - FORMAT_DATE_4_OUTPUT to convert the date in the same format fro both the dates and then compare them.
Edited by: Sachin86 on Aug 10, 2010 8:52 AM
‎2010 Aug 10 8:25 AM
Hi,
DATA : v1 type char10,
v2 type sy-datum.
DATA : v3 type char10.
Write: v2 to v3.
Now you can compare v1 with v3.
Hope this helps.