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

Problem in date field comparison

Former Member
0 Likes
624

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

3 REPLIES 3
Read only

Former Member
0 Likes
518

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,

Read only

Former Member
0 Likes
518

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

Read only

Former Member
0 Likes
518

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.