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

time comparision

Former Member
0 Likes
1,259

hi,

i need to check the current system time is 3.00 or not and if it is 3.00 i need to execute something can u guys plz suggest me how to compare time.

urgent plz.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,225

Hi Ravi

1) create a variable like sy-UZEIT and assign value as SY-uzeit to it ..

2) create another varaible like sy-uzeit and assign ur value i.e '03:00:00' to it.

3) now compare like

if ur_variable = sys_time .

.........

else.

......

endif.

Regards

Chandrika.

10 REPLIES 10
Read only

Former Member
0 Likes
1,225

hi Ravi,

Make use of <b>SY-UZEIT</b> Variable to compare time ...

it is a 6 character variable which contains values in this fashion i.e, hhmmss...


data : v_hour(2) value '3',
       v_time like sy-uzeit.


   if v_time+0(2) = v_hour.

   endif.

Read only

Former Member
0 Likes
1,225

Hi Ravi ,

Current time is in the system field sy-UZEIT , it is in the format hhmmss.

You can check if the time with your said time.

But could you please tell me why you have such a requirement , if you want a program to be exeucted every day at 3:00 hrs you can schedule it in background and the system will take care of it .

Regards

Arun

Read only

Former Member
0 Likes
1,225

1) create a variable like sy-UZEIT and assign value as SY-uzeit to it ..

2) create another varaible like sy-uzeit and assign ur value i.e '030000' to it.

3) now compare like

if ur_variable = sys_time .

.........

else.

......

endif.

Read only

Former Member
0 Likes
1,225

make use of system fields

SY-UZEIT.

Reards

Prabhu

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
1,225

HI,

You can get the time using the system variable sy-uzeit.

I dont think you want to compare even seconds. so i have coded for only hours and minutes.

DATA: ch(4) TYPE c.

ch = sy-uzeit.

WRITE: ch.

if ch = '0300' or ch = '1500'.

endif.

This should work.

Regards,

Sesh

Message was edited by:

Seshatalpasai Madala

Read only

Former Member
0 Likes
1,226

Hi Ravi

1) create a variable like sy-UZEIT and assign value as SY-uzeit to it ..

2) create another varaible like sy-uzeit and assign ur value i.e '03:00:00' to it.

3) now compare like

if ur_variable = sys_time .

.........

else.

......

endif.

Regards

Chandrika.

Read only

Former Member
0 Likes
1,225

Hi

Check the SY-UZEIT.

If it is 3.00 then perform the operation

Thanks

Shiva

Read only

Former Member
0 Likes
1,225

Hi Ravi

data: g_time type string.

g_time - sy-uzeit.

if g_time EQ 3.00.

<then execute something >

ENDIF.

PLZ REWARD POINTS IF HELPFUL

Read only

Former Member
0 Likes
1,225

You can get the system time from sy-uzeit.

Use it to get the time and manipulate as required.

Check the code below:


*&---------------------------------------------------------------------*
*& Report  ZMADHU_UZEIT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZMADHU_UZEIT.

data: v_time type sy-uzeit.
v_time = sy-uzeit.

IF v_time(2) ne 3.    "Check the hour
WRITE / v_time.
else.
  write / 'Time'.
ENDIF.

Regards

Read only

Former Member
0 Likes
1,225

hi,

g_hh(2) type c.

g_hh = sy-uxeit+0(2).

if g_hh = '03'

ur case.

endif.

hope this helps