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 and date

former_member611341
Participant
0 Likes
1,351

Hello guys,

I have a date(07/26/2006) and time (17:07:46)fields.

I have to condition to check if it is crossed two days ( i.e 24 hrs ) how shud i add exactly 2 days (or 24 hrs ) to this this date and time field.

like shud i add 2 days to date? if so how?

or any other solution?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,305

You can try this FM RP_CALC_DATE_IN_INTERVAL.

(it is workin tested...)

call function 'RP_CALC_DATE_IN_INTERVAL'

exporting

date = sy-datum

days = 3

months = 0

signum = '+'

years = 0

importing

calc_date = wa_date.

Hello guys,

I have a date(07/26/2006) and time (17:07:46)fields.

I have to condition to check if it is crossed two days ( i.e 24 hrs ) how shud i add exactly 2 days (or 24 hrs ) to this this date and time field.

like shud i add 2 days to date? if so how?

or any other solution?

9 REPLIES 9
Read only

Former Member
0 Likes
1,306

You can try this FM RP_CALC_DATE_IN_INTERVAL.

(it is workin tested...)

call function 'RP_CALC_DATE_IN_INTERVAL'

exporting

date = sy-datum

days = 3

months = 0

signum = '+'

years = 0

importing

calc_date = wa_date.

Read only

Former Member
0 Likes
1,305

Yes, u can add '2' to the date variable u r having now. That will solve ur problem.

Read only

0 Likes
1,305

IF just add 2 to date ...in that case i have to check time...is it same or less or greater.

coz i need exactly 24 hrs added to date and time.....

Read only

0 Likes
1,305

thnks guys for all your quick responses....

Read only

0 Likes
1,305

Hi Aday,

If you specically want to add only hours then use this function module <b>CATT_ADD_TO_TIME</b>.

DATA V_DATE TYPE SY-DATUM VALUE '20060726'.

DATA V_TIME TYPE SY-UZEIT VALUE '170746'.

DATA V_DATE1 TYPE SY-DATUM VALUE '20060726'.

DATA V_TIME1 TYPE SY-UZEIT VALUE '170746'.

CALL FUNCTION 'CATT_ADD_TO_TIME'

EXPORTING

idate = V_DATE

itime = V_TIME

stdaz = '2400' -->Specify hours with minutes

IMPORTING

EDATE = V_DATE1

ETIME = V_TIME1.

WRITE:/ V_DATE1, V_TIME1. -->Will contain new date and time afte adding STDAZ hours with mintues.

Thanks,

Vinay

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,305

Aday, just add 2 to the date.

data: this_date type sy-datum.

this_date = sy-datum .

this_date = this_Date + 2.

To be clear, adding 2 days will add 48 hours, not 24.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,305

Hi Aday,

Just add 2 to date field and check for condition.

DATA V_DATE1 TYPE SY-DATUM VALUE '20062607'.

DATA V_TIME TYPE SY-UZEIT VALUE '170746'.

DATA V_DATE2 TYPE SY-DATUM.

V_DATE2 = V_DATE1 + 2.

IF V_DATE <= V_DATE2 AND V_TIME <= V_TIME1.

WRITE:/ 'DOESNT CROSS 2 DAYS'.

ELSE.

WRITE:/ 'CROSSED 2 DAYS'.

ENDIF.

Thanks,

Vinay

Read only

former_member611341
Participant
0 Likes
1,305

I have a tbale with some fields.

lets say 3 fields xxx ,date (07/26/2006 )

and time(17:07:46) .

i want to select xxx from table only if it is two days or more older.

that's what i need .

may be i shud have asked question clearly...

Read only

0 Likes
1,305

Hi Aday,

Try with this code.

DATA V_DATE TYPE SY-DATUM.

V_DATE = SY-DATUM - 2.

LOOP AT ITAB WHERE DATE >= V_DATE.

WRITE:/ ITAB-XXX.

  • You have XXX values so now code as per your need here

ENDLOOP.

Thanks,

Vinay