# How to compare data (up or down) based on monthly date

Hi group,

I have a report that has data for each month.This report will be run every on 1st of every  month. The report will have to display sells and whether the sales are going up or down based on 1st of each month. I need help with the code. How do I compare the dates? How do I tell the program which date is previos when comparing to the current one?

Thank you

gal
###### Who is Participating?

Commented:
Use the offset to identify the period and explicitly handle the 01 to 12 conversion.
This assumes that the internal format of the period field is YYYYMM which it should be ....

if p_period+4(2) = 01.

g_period(4) = g_period(4) - 1.
g_period+4(2) = 12.

else.

g_period = p_period -1.

endif.

Cheers
Jon
0

Commented:
if you have the dates in a date field with a domain of datum ( which most are ) then you can simply use the <> operators.

Jon
0

Commented:
try this noddy program ....

REPORT zzjontest LINE-SIZE 255 LINE-COUNT 60 NO STANDARD PAGE HEADING.

parameters: p_dat1 like sy-datum ,
p_dat2 like sy-datum default sy-datum.

write: / 'date 1 ', p_dat1,  'is  '.

if p_dat1 > p_dat2.
write: 'After '.
else.
write: 'Before '.
endif.

write:  'date 2' , p_dat2.
0

Author Commented:
Thanks for the suggestion.

I did pretty much the dame thing. I select all data in one intrnal table where PERIOD= P_PERIOD
and than I specify G_PERIOD = P_PERIOD - 1. Again I select all the data where PERIOD = G_PERIOD.

But there is one problem. If an user selects 2005/01 as selection option than the program will read the old period as 2005/00. Do you have any idea how can I reset the code to skip bening 00 af the end?

Thanks again

Galin
0

Author Commented:
Nice,

Thanks Jon
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.