‎2009 Jan 22 12:00 PM
hi all,
i have the following requirement
in a function module i have import parameter of type string
theres an table with one of its field to be of type dats
in the function module i am getin the from d db those records that have this date value by comparing my import param with the db value.
how do i compare char and date...is there any conversion in either way.
Regards
Jayapriya
‎2009 Jan 22 12:12 PM
hi
have a look onthis code...Its helpfull only if the string's first 2 place holds date ,next two place has month and other four has year ...
REPORT ZDATEDIFF .
data :var3 type sy-datum.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = '11092008'
IMPORTING
date_internal = var3
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
write var3.
if you wanna convert the string like bellow
lv_date = '2006-12-07' then use this code .
DATA : lv_date(15) type C ,L_VAR2 like sy-datum.
lv_date = '2006-12-07'.
CONCATENATE lv_date8(2) '.' lv_date5(2) '.' lv_date(4) INTO lv_date.
write lv_date.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
DATE_EXTERNAL = lv_date
IMPORTING
DATE_INTERNAL = L_VAR2
EXCEPTIONS
DATE_EXTERNAL_IS_INVALID = 1
OTHERS = 2.
write : L_VAR2.
hope the content is usefull
regards
R@SAP.
Edited by: R@SAP on Jan 22, 2009 1:22 PM
‎2009 Jan 22 12:01 PM
‎2009 Jan 22 12:06 PM
hi.
character formats can always be compared,u insert the date field to character field and compare.
Edited by: soniya baboo on Jan 22, 2009 1:07 PM
‎2009 Jan 22 12:12 PM
hi
have a look onthis code...Its helpfull only if the string's first 2 place holds date ,next two place has month and other four has year ...
REPORT ZDATEDIFF .
data :var3 type sy-datum.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
date_external = '11092008'
IMPORTING
date_internal = var3
EXCEPTIONS
date_external_is_invalid = 1
OTHERS = 2.
write var3.
if you wanna convert the string like bellow
lv_date = '2006-12-07' then use this code .
DATA : lv_date(15) type C ,L_VAR2 like sy-datum.
lv_date = '2006-12-07'.
CONCATENATE lv_date8(2) '.' lv_date5(2) '.' lv_date(4) INTO lv_date.
write lv_date.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
DATE_EXTERNAL = lv_date
IMPORTING
DATE_INTERNAL = L_VAR2
EXCEPTIONS
DATE_EXTERNAL_IS_INVALID = 1
OTHERS = 2.
write : L_VAR2.
hope the content is usefull
regards
R@SAP.
Edited by: R@SAP on Jan 22, 2009 1:22 PM
‎2009 Jan 22 12:14 PM
Take the Local Variable of Date Type and You can send the Value into that variable
‎2009 Jan 22 12:21 PM
‎2016 Mar 30 1:40 PM