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

Comparing DATES.

Former Member
0 Likes
1,412

Hi everyone , I`m trying to compare two dates , one of them is the field planfinish (type: DEC 15 ) of cgpl_task table in CRM , it has the format : 31.10.2006 03:59:00 , the other date is sy-datum. But I don`t know what can I do ? ,

For example the next select bring me all registers , it doesnt care about t1~planfinish > sy-datum condition .

SELECT t2objnr t1guid t1external_id t1planfinish t2~stat INTO TABLE ti_campaut

FROM cgpl_task AS t1

INNER JOIN crm_jest AS t2

ON t1guid = t2objnr

WHERE t1~object_type = 'CPT'

AND t2~inact = ' '

AND t2~stat = 'I1122'

AND t1~planfinish > sy-datum .

any help. ?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
820

if you don't need the time stamp truncate the date with time stamp in the sy-datum format and compare.

Or else try other system fields like sy-uzeit.

concatenate sy-datum and sy-uzeit and use it in ur select

Message was edited by:

Vinni

Message was edited by:

Vinni

3 REPLIES 3
Read only

Former Member
0 Likes
821

if you don't need the time stamp truncate the date with time stamp in the sy-datum format and compare.

Or else try other system fields like sy-uzeit.

concatenate sy-datum and sy-uzeit and use it in ur select

Message was edited by:

Vinni

Message was edited by:

Vinni

Read only

0 Likes
820

hey is ur problem solved ? if yes award points and close the thread.

Read only

Former Member
0 Likes
820

Hi Ali,

Can you tell in which format the date is coming in field planfinish after writing select query?

e.g. 31102006 (DDMMYYYY) or 10312006 (MMDDYYY) etc.

If the date in palnfinish is coming in DDMMYYYY format the you need to check Date format of sy-datum. Most of the time it is YYYYMMDD. In this case before comparing you need to format the sy-datum field in another variable. e.g. Here sy-datum is in YYYYMMDD format.

DATA: v_date(8) TYPE c,

v_date2(15) TYPE c.

v_date4(4) = sy-datum0(4).

v_date2(2) = sy-datum4(2).

v_date0(2) = sy-datum6(2).

You can make v_date in same sequence as planfinish.

If palnfinish is having TIME also then declare another variable of length 15 & concatenate the v_date & sy-uzeit into that variable & then compare.

Concatenate v_date sy-uzeit into v_date2.

Now compare this v_date2 with palnfinish field.

Ashven