Application Development 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: 

QUERRY FOR LAST 20 MINUTES FROM THE CURRENT TIME

Former Member
0 Kudos

hi i need to query one database table for the last 20 minutes from the current time, please let me know how to write the logic for this...

thanks for your help

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Sudhir,

You will have to consider couple of cases here.. for example you execute the report at 00:10 am of a day.. The date is already changed and if you will only code for the logic, then you will get wrong results..

Do as below:

MOVE sy-uzeit TO w_time.

IF w_time LT '002000'.

w_time1 = '235959' - w_time.

w_date1 = sy-datum - 1.

SELECT xxx

FROM yyy

INTO zzz

WHERE ( time GT w_time1

AND date EQ w_date1 )

OR ( time LT w_time

AND date EQ sy-datum ).

ELSE.

w_time1 = sy-uzeit - '002000'.

SELECT xxx

FROM yyy

INTO zzz

WHERE time GT w_time1

AND date EQ sy-datum.

ENDIF.

Thanks and Best Regards,

Vikas Bittera.

<b><REMOVED BY MODERATOR></b>

Message was edited by:

Alvaro Tejada Galindo

7 REPLIES 7

Former Member
0 Kudos

Do you have a time field in the database table that you want to query.

DATA : lv_time TYPE sy-uzeit.

lv_time = sy-uzeit - 1200.

select * from table where time >= lv_time .

0 Kudos

HI thank you,

i have the time field i.e lqua-ezeit. please let me know what to do

0 Kudos

What do you do if the time is just after midnight? Shouldn't you also take LQUA-EDATU into account?

Rob

0 Kudos

hi i need to query lqua for the EDATU(today's date) time(EZEIT) for the last 20 minutes from the current time. please let me know what to do.thanks for your help.

0 Kudos

HI,

DATA : lv_time TYPE sy-uzeit.

lv_time = sy-uzeit - 1200.

select * from lqua into table itab where edatu eq sy-datum and ezeit >= lv_time .

Former Member
0 Kudos

Hi Sudhir,

You will have to consider couple of cases here.. for example you execute the report at 00:10 am of a day.. The date is already changed and if you will only code for the logic, then you will get wrong results..

Do as below:

MOVE sy-uzeit TO w_time.

IF w_time LT '002000'.

w_time1 = '235959' - w_time.

w_date1 = sy-datum - 1.

SELECT xxx

FROM yyy

INTO zzz

WHERE ( time GT w_time1

AND date EQ w_date1 )

OR ( time LT w_time

AND date EQ sy-datum ).

ELSE.

w_time1 = sy-uzeit - '002000'.

SELECT xxx

FROM yyy

INTO zzz

WHERE time GT w_time1

AND date EQ sy-datum.

ENDIF.

Thanks and Best Regards,

Vikas Bittera.

<b><REMOVED BY MODERATOR></b>

Message was edited by:

Alvaro Tejada Galindo

Former Member
0 Kudos

Hi Sudhir,

Instead of taking N type value you can take integer value of 1200..

So, IF w_time LT 1200. Like this.. without considering this case, your application might give wrong data some time..

Thanks and Best Regards,

Vikas Bittera.

<b><REMOVED BY MODERATOR></b>

Message was edited by:

Alvaro Tejada Galindo