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

Convert Date to Char

Former Member
0 Likes
2,418

In the selection screen using select options the user enters a date. This field has to be compared to a 10 character field.

However in the debugging mode I see the date entered is 'IBT2007051020070512' How do i compare this with the character format...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,911

Supposed that your screen field is called S_DATE....You would need to do this...


IF MY_DATE BETWEEN S_DATE-LOW AND S_DATE-HIGH.
*Do something...
ELSE.
*Show error...
ENDIF.

MY_DATE must be in DATE internal format....20070620.

Greetings,

Blag.

In the selection screen using select options the user enters a date. This field has to be compared to a 10 character field.

However in the debugging mode I see the date entered is 'IBT2007051020070512' How do i compare this with the character format...

9 REPLIES 9
Read only

Former Member
0 Likes
1,911

As u know IBT2007051020070512 means date ranges from 05/10/2007 to 05/12/2007

Now which date u want to handle is the ques. may be lower date or higher

s_date-lower gives the lower date

s_date-higher gives the higher date.

make a temp var with char(10) and assing the correct value to it.

nd do the comparision.

Thanks & regards

vinsee

Read only

Former Member
0 Likes
1,912

Supposed that your screen field is called S_DATE....You would need to do this...


IF MY_DATE BETWEEN S_DATE-LOW AND S_DATE-HIGH.
*Do something...
ELSE.
*Show error...
ENDIF.

MY_DATE must be in DATE internal format....20070620.

Greetings,

Blag.

Read only

Former Member
0 Likes
1,911

Hi Alexander,

I need some more informations but i think I can help you.

"However in the debugging mode I see the date entered is 'IBT2007051020070512' "

It happens because you are using a select-options, and so, the entered values are organized in the structure of the select-options ( SIGN, OPTION, LOW, HIGH).

Double-Click on the selection-options field at debug screen to see it's structure.

What kind of comparison do you need to do?

Do you need to see if the date in character format was typed onm the selection-screen?

I need more details to write you a sample code.

Regards.

Read only

Former Member
0 Likes
1,911

Hi

In select-options you see the output format, in debbug you see the real form used to store the date, u should use this format, so u should translate the char format to input format.

SELECT-OPTIONS SO_DATE FOR SY-DATUM.

DATA: DATE(10) VALUE '20.06.2007',
           DATE_IN TYPE SY-DATUM.

DATE_IN(4)     = DATE+6(4).
DATE_IN+4(2) = DATE+3(2).
DATE_IN+6(2) = DATE(2).

IF DATE_IN IN SO_DATE.
* do something
ENDIF.

Max

Read only

rodrigo_paisante3
Active Contributor
0 Likes
1,911

Hi

you can create a var type string

x type string.

x = s_data-low.

X receive the LOW option. now you can compare with a var type character format.

Regards

Read only

Former Member
0 Likes
1,911

You have opened a lot of posts for the same question. Please use one thread to continue and close the rest.

Read only

0 Likes
1,911

I agree that but still my question is unanswered.

Can you please help me.

Read only

0 Likes
1,911

Even if your question is not answer...You can't duplicate posts...

And maybe you need to reformulate your question...because you have recieve a lot of answers....None of them helps you to fulfill your need???

Greetings,

Blag.

Read only

0 Likes
1,911

Hi

See my answer above, you need to transform the char in a date format.

Max