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

Select date whithout year.

Former Member
0 Likes
2,310

how can I filter a date without year, considering only the day and the month.

Example: SELECT * FROM KNVK WHERE GBDAT BETWEEN '%0101' AND '%0131' to select the contacts whom was born in january. This instruction doesn't work.

Any one has a suggestion?

how can I filter a date without year, considering only the day and the month.

Example: SELECT * FROM KNVK WHERE GBDAT BETWEEN '%0101' AND '%0131' to select the contacts whom was born in january. This instruction doesn't work.

Any one has a suggestion?

15 REPLIES 15
Read only

andreas_mann3
Active Contributor
0 Likes
1,658

try:

SELECT * FROM knvk

WHERE gbdat LIKE '____01__'

...

A.

Message was edited by:

Andreas Mann

Read only

0 Likes
1,658

Ok, but the user can enter with the initial and the final date, for example:

'____0101' to '____0501'

The commands 'between' with 'like' doesn't work, need other alternative.

Regards.

Read only

0 Likes
1,658

Hi,

so you must collect all possible values in a range

blessed weekend and christmas

to all SDN'ers

Andreas

Read only

0 Likes
1,658

Hi Diovani,

You can code it without using <b>between</b> like;

Select * from Tablename where gdatum like '____0101' OR gdatum like '____0131'.

Try this and please reward if helpful.

Thanks.

Read only

Former Member
0 Likes
1,658

Hi Diovani,

You can use SELECT * FROM KNVK WHERE GBDAT <b>like</b> '____0130'.

_ : means one character field.You can use(four of ) it for year...

You have to use _ instead of + if your database server is oracle.

Reward if helpful.

Thanks.

Read only

0 Likes
1,658

Ypu can use:

WHERE endda LIKE '____0101'.

f [NOT] LIKE g

Addition:

... ESCAPE h

Effect

The condition is met for a table entry if the statement "f (does not) equal the pattern in g" is true for the values of f and g. f must always be a field descriptor, and g an ABAP field or an ABAP string. If f has the value NULL, then the result of the check for the statement is unknown. Within a pattern, there are two special characters:

'_' (underscore) stands for any single character.

'%' (percentage sign) stands for any sequence of characters, including an empty string.

Lucky

Read only

Former Member
0 Likes
1,658

try this code:

Data: date_in type sy-datum,

date_out(10) type c.

Date_in = sy-datum.

Concatenate Date_in4(2) Date_in6(2) into date_out separated by '/'.

Write: Date_out.

if its useful plz reward me.

Read only

Former Member
0 Likes
1,658

Is it just month beginnings and endings or can the user enter mid-month dates?

Rob

Read only

0 Likes
1,658

Experts,

Sorry if I cant explain it better.

But I need a range between the initial and final dates.

So if the user inform the first date '01.01' and the final '12.06' I need to collect ALL the data between them (without considering the year).

Thnx.

Read only

0 Likes
1,658

Brute force:

REPORT ztest MESSAGE-ID 00.

TABLES knvk.

PARAMETERS: lo_mo(2),
            hi_mo(2),
            lo_day(2),
            hi_day(2).

SELECT * FROM knvk WHERE
  NOT gbdat EQ '00000000'.

  IF knvk-gbdat+4(2) >  lo_mo AND
     knvk-gbdat+4(2) <  hi_mo OR
   ( knvk-gbdat+4(2) =  lo_mo AND
     knvk-gbdat+6(2) >= lo_day ) OR
   ( knvk-gbdat+4(2) =  hi_mo AND
     knvk-gbdat+6(2) <= hi_day ).

* Process

  ENDIF.

ENDSELECT.

Rob

Read only

Former Member
0 Likes
1,658

I wish I could solve it by OPEN SQL instructions, but now I think it was not possible without using native SQL.

Thanks for all the help.

Read only

0 Likes
1,658

I think you'll find native SQL slower.

Rob

Read only

0 Likes
1,658

I have no much experience in this kind of development, so I cant see why it will be slower.

Regards.

Read only

0 Likes
1,658

I recall running a test a few years ago, expecting to find native SQL faster, but the opposite was true. I don't know the reason but suspect that buffering may be involved.

In any event, if i can use open SQL and ABAP, then that would be the way I would go.

Rob

Read only

0 Likes
1,658

I will consider these points.

I think its really make sense