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: 

time comparison.

Former Member
0 Kudos

Hai,

Thanks for your kind assistance.

I want to check whether Current time

is between 16:00 and 21:00

do we have any Function?

Regards

Chandra kumar.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi dear chandra kumar,

One can use this logic :

*----


report abc.

data : t1 type sy-uzeit,

t2 type sy-uzeit.

t1 = '1600'.

t2 = '2100'.

write 😕 sy-uzeit.

if sy-uzeit >= t1 and sy-uzeit <= t2.

write : 'current time is in between ' , t1 , 'and' , t2.

else.

write : 'current time is NOT in between ' , t1 , 'and' , t2.

endif.

*----


I have opened my account in sdn for the first

time today and this is my first reply to you.

I Hope your purpose is solved.

Please give point if u feel satisfied.

Thanks & Regards,

Amit Mittal.

6 REPLIES 6

Former Member
0 Kudos

Hi dear chandra kumar,

One can use this logic :

*----


report abc.

data : t1 type sy-uzeit,

t2 type sy-uzeit.

t1 = '1600'.

t2 = '2100'.

write 😕 sy-uzeit.

if sy-uzeit >= t1 and sy-uzeit <= t2.

write : 'current time is in between ' , t1 , 'and' , t2.

else.

write : 'current time is NOT in between ' , t1 , 'and' , t2.

endif.

*----


I have opened my account in sdn for the first

time today and this is my first reply to you.

I Hope your purpose is solved.

Please give point if u feel satisfied.

Thanks & Regards,

Amit Mittal.

0 Kudos

Hello Amit,

It's nice to know that we have a new member here at SDN. A hearty welcome to you. Hope to have a lot of discussions where we could share some interesting stuff.

Regards,

Anand Mandalika.

andreas_mann3
Active Contributor
0 Kudos

Hi ,Chandrea,

If sy-uzeit between '16:00' and '21:00'.

...

Andreas

Former Member
0 Kudos

Hello Chandra,

There's a small point that I would like to make. Though it is a good idea to use the exisitng Function Modules to meet our requirements, it is not very wise to always spend much time in searching for a Function Module in cases as simple as this one.

There are several ways in which you can check for the condition you want- The following is one of them...


if sy-uzeit between '080000' and '210000'.
* Do the processing.
endif.

Regards,

Anand Mandalika.

0 Kudos

This logic does not work if the time interval goes across midnight.

For example, lets say I want to check whether 02:00:00 is between 22:00:00 and 04:00:00.

Does anybody have a more robust logic for doing time comparison?

0 Kudos

You will probably get more response if you open your own thread.

Before you start, you have to know the date of all three times..

Rob