• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

flag record based on range for dates

S_BEGDA    H_BEGDA   S_endda
20100419  20100705   99991231
20031016  20080623   20090331

i want to flag H_BEGDA as Y and other as N on the condition that 20100705 range not between S_BEGDA  and  S_endda while other in between the range

i am doing
Case When H_Begda not BETWEEN S_Begda And S_Endda Then 'Y' Else 'N' End As Test1 both record show me Y

S_BEGDA    H_BEGDA   S_endda  
20100419  20100705   99991231 Y
20031016  20080623   20090331 N
  • 2
1 Solution
slightwv (䄆 Netminder) Commented:
I don't understand.

I run your test and I get 'N' for both.

20100705 is between 20100419 and 99991231
and 20080623 is between 20031016  and 20090331

What am I missing?
sam2929Author Commented:
My bad question don't make sense
DavidSenior Oracle Database AdministratorCommented:
This is just an old developer's trick, but I was taught to avoid NOT conditions if the statement could be reworded.  Such as:

Case When H_Begda BETWEEN S_Begda And S_Endda Then 'N' Else 'Y' End As Test1

Is your source data clean enough that you don't need to check for misformatted strings?  Would you ever have, for example, 30131332?  If so, what are the business rules?
slightwv (䄆 Netminder) Commented:
>>My bad question don't make sense

As much as I appreciate the points, did I really help you answer you question?

If not and you are going to ask a new question, I suggest we just delete this one.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now