cancel
Showing results for 
Search instead for 
Did you mean: 

isDate() Function

Murali_Shanmu
Active Contributor
0 Kudos

Hi

I have a string that contains date as '10.10.2005'. Now how do i confirm if the string is a date. In short i need to achieve isDate () functionality like in other languages.

Can i try using

SEARCH <String> FOR '*.2005'.

Or is there any better way of using FM to achieve this.

Suggestion regarding this are welcome !!!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi again,

1. i tried ur query again, but its working FINE.

2. try this FM

CONVERT_DATE_TO_INTERN_FORMAT

3. if u give : 10.10.2005 --- OK

2345 --- invalid date

20051010 --- OK

31.11.2005 --- invalid date (november does not have 31 days)

4. I think this is what is required (if

im wrong, pls let me know)

5. This FM will take care of all date formats

whether : dd.mm.yyyy or YYYYMMDD.

6. The pervious PLAUSIBLE function module

has contraint (as i had already mentioned)

of date input in YYYYMMDD format.

Hope it helps.

regards,

amit m.

Message was edited by: Amit Mittal

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Again,

THIS NEW FUNCTION DOES NOT HAVE PROBLEM

OF DATE FORMAT

AS THE FM DATE_CHECK_PLAUSIBILITY

MENTIONED IN MY PREVIOUS POST.

1. Got another FM

CONVERT_DATE_TO_INTERN_FORMAT

2. Try this code (Just copy paste)

REPORT abc NO STANDARD PAGE HEADING.

data : s(10) type c.

s = '3.11.2005.'.

data : err type c.

*----


CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'

EXPORTING

datum = s

dtype = 'DATS'

IMPORTING

ERROR = err

  • IDATE =

  • MESSG =

  • MSGLN =

.

*----


write 😕 err.

BREAK-POINT.

Hope it helps.

Regards,

Amit M.

Message was edited by: Amit Mittal

Murali_Shanmu
Active Contributor
0 Kudos

Hi

I used these Function Modules. If i give '10.10.2005' and also '2345' the FM will say both are not dates. But i need it to distinguish between numbers and Date. Date format is '10.10.2005'. I need a Function Module that can differentiate this Date with a string that contains numbers say '123456'.

Former Member
0 Kudos

Murali,

The DATE_CHECK_PLAUSIBILITY func module will tell you whether it is a valid date or not. However, the input for this should be in the internal format. So, you convert your input into the internal format and then give that as the input to this.

So in your example the input should 20051010 and it should tell you that its a valid date. (YYYYMMDD).

Now, if your number / string is in such a way it also can represent a date, then we do have a problem.

Regards,

Ravi

Murali_Shanmu
Active Contributor
0 Kudos

Thanks Amit and Ravi. I finally got it working with 'CONVERT_DATE_TO_INTERN_FORMAT'. I did not realise the date in the sample code was Invalid one. Now it meets my requirement.

Thanks a Lot.

Former Member
0 Kudos

Hi Muralidaran,

1. One way is using FM

DATE_CHECK_PLAUSIBILITY

2. Only one constraint is that it expects

the date in YYYYMMDD format.

3. Mean while im searching for ur exact requirement.

Hope it helps.

Regards,

Amit M.

Former Member
0 Kudos

Murali,

You should be able to use the function DATE_CHECK_PLAUSIBILITY for this purpose.

Regards,

Ravi

Note : Please reward points if this helps.