12-17-2007 12:48 PM
Hi ,
In My program i need to compare date and time value
with current date and time , If DATE & TIME is in the
future, I need to set the DATE & TIME to NOW.
Please help me if you know any FM or sample code
To compare the dates and time.
Thanks in advance,
RK.
12-17-2007 12:52 PM
Hi,
You can use the below :
data : date like sy-datum value '20071231'.
data : time like sy-uzeit value '121212'.
at selection-screen.
if date GT sy-datum.
date = sy-datum.
endif.
if time GT sy-uzeit.
time = sy-uzeit.
endif.
.
Thanks,
Sriram Ponna.
12-17-2007 1:00 PM
Hi sriram,
Thanks for response,
I want to compare date and time at a time, Not individually.
Please help.
Thanks,
RK.
12-17-2007 1:10 PM
Hi Ravi,
Please check the FM SD_DATETIME_DIFFERENCE.
In the result if you get difference is 1.
Then you can reset the date and time to current.
Thanks,
Sriram Ponna.
12-17-2007 12:52 PM
Hi,
You can do like this
Loop at itab into wa.
if wa-date NE sy-datum and wa-time NE sy-uzeit.
wa-date = sy-datum.
wa-time = sy-uzeit.
modify itab from wa transporting date time.
clear wa.
endif.
endloop.
Regards,
Satish
12-17-2007 12:57 PM
DATE_COMPUTE_DAY
DATE_GET_WEEK
hi put in a condition saying
if sy-datum > ur date
ur date = sy-datum.
endif.
if sy-uzeit > ur time
ur time = sy-uzeit.
endif.
12-17-2007 1:00 PM
hi,
a) Check this FM 'HR_HK_DIFF_BT_2_DATES'.
b) think this two function modules can help u out..just let me know were this useful..
SD_DATETIME_DIFFERENCE
Give the difference in Days and Time for 2 dates
FIMA_DAYS_AND_MONTHS_AND_YEARS
Get number of days. Year, Months between two dates.
by using either of one u can get the difference, if difference is -ve , set date and time to system date and time
regards,
pavan
12-17-2007 1:06 PM
Hi Ravi,
Try any one of this function modules in these you compare sy-datum and sy-uzeit..
HRVE_GET_TIME_BETWEEN_DATES
CX_SCHED_VIA_OPERATING_TIME
SD_DATETIME_DIFFERENCE
SD_CALC_DURATION_FROM_DATETIME
Plz Reward if useful.
Mahi.
12-17-2007 1:21 PM
Hi
Ravi
as they said you can use FM
or if u want logic dont compare date and time explicitly
do like this
data:
w_d1 int i,
w_t1 type i,
w_d2 type i,
w_t2 type i,
w_d1 = sy-datum.
w_t1 = sy-uzeit.
w_d2 = ur_date.
w_t2 = ur_time.
if (w_d1 + w_t1 ) le ( w_d2 + w_t2 ) .
ur_date = sy-datum.
ur_time = sy-uzeit.
endif.
plzzz reward if useful dont forget to reward plzz
12-17-2007 1:21 PM
Hi
Ravi
as they said you can use FM
or if u want logic dont compare date and time explicitly
do like this
data:
w_d1 int i,
w_t1 type i,
w_d2 type i,
w_t2 type i,
w_d1 = sy-datum.
w_t1 = sy-uzeit.
w_d2 = ur_date.
w_t2 = ur_time.
if (w_d1 + w_t1 ) le ( w_d2 + w_t2 ) .
ur_date = sy-datum.
ur_time = sy-uzeit.
endif.
plzzz reward if useful dont forget to reward plzz
12-17-2007 2:24 PM
Hi sunil kumar,
Thanks for response.
I didnt uinderstand you below logic, How to compare this.
if ( w_d1 + w_t1 ) le ( w_d2 + w_t2 ) .
endif.
Thanks,
RK
12-17-2007 2:33 PM
Hi ravi,
1. this is a TRICKY logic
2. suppose the date and time variables are d and t.
and current date and time is sy-datum, sy-uzeit.
3.
*------ compare if date and time are greater than NOW
if (d > sy-datum) or
(d = sy-datum and t > sy-uzeit).
d = sy-datum
t = sy-uzeit.
endif.
regards,
amit m.
12-10-2013 2:59 PM
Hello Amit,
I had a similar issue ( a bit more complex though ), your reply has helped me fix it. Thanks.
Regarda,
Mohammed Muzammil.