Application Development 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: 

How to compare the date field

Former Member
0 Kudos

Hi friends,

I have a small problem, actually i have a date field , the format of the date field is "dd.mm.yyyy" but my client asked the date compareson , incase the user enters the wrong format dd/mm/yyyy that time the system shows the error message.

for example

My date format = dd.mm.yyyy => 03.03.2009

incase the user enter the wrong format => 03/05/2009 in this case the user wants the message

how to compare the date field format "dots / - '.

thanks

chinnu

5 REPLIES 5

Former Member
0 Kudos

data: date(8) type c.

date = 12/06/2009

if date ca '/'

error message

endif.

0 Kudos

Hi Brighside

Thansk for sending the answer, i have a small doubt,

what is the use of the 'ca',.

Thanks

chinnu

0 Kudos

ca : contains any(used for string operations)

Former Member
0 Kudos

Hello,

The date format can be separated by dots or / depending on the date settings on your system.

You can avoid confusions on this by using write statement.

w_date1 = sy-datum.

Write w_date to w_date1.

You can compare the dates by taking it on to a character string and then use the EQ operator.

If w_date1 eq w_date2.

.....

endif.

Thanks,

Sowmya

Former Member
0 Kudos

Hi

The problem is to know which kind of variable you're using for field date, if it's SY-DATUM u can't know the output format used by user, because you always see the format YYYYMMDD.

U should consider the format depends on setting of the user.

Max