473,511 Members | 16,769 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Statement returing True/False in decode() function

Hi,

I want to write a query that returns Y or N depending on whether the
current time is within a specified window i.e.

EVENT_TABLE
----------
event_id number PK
event_start date
event_end date

I tried this:
SELECT event_id,
decode( sysdate between event_start and event_end, TRUE, 'Y',
'N')
FROM event_table

Unfortunately, Oracle won't accept a boolean expression inside the
decode function.

I've accomplished what I want via a correlated sub-query:

SELECT event_id,
nvl((SELECT 'Y' from event_table e2
WHERE sysdate between event_start and event_end
AND e.event_id=e2.event_id),'N')
FROM event_table e

But I'm wondering if there's a more aesthetic way to do it. Is there a
way to feed an expression that evaluates to true-or-false to the first
argument of the decode function?

Thanks.

--
//-Walt
//
//
Jul 19 '05 #1
1 23255

Try this:

...
decode(sign(sysdate-event_start),-1,'N'
,decode(sign(event_end-sysdate),-1,'N','Y'))
...

also you can use:
...
case
when sysdate between event_start and event_end
then 'Y' else 'N'
end as date_flag
...

--
Posted via http://dbforums.com
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2252
by: brainsucker | last post by:
Hi My name is Juan Carlos Rodrigo, and I love Python. It is the most impressive and usefull language that I have ever seen. I am studing, at http://www.uoc.edu, an Information Technology...
3
1716
by: Mark Morton | last post by:
I'm writing an if statement for a UK credit card form validation script. Users who specify that their card is Switch need to enter either the issue number or the 'valid from' date. I'm trying to...
11
14265
by: Craig Francis | last post by:
Ok I'm making a fairly simple application. It contains 2 web browsers, the top one is used so that you can view a website (i.e. one you have created). Every time you load a page, the HTML which...
4
9178
by: dkelly925 | last post by:
I have an Access Report that I am trying to enter an "If Statement" that when a certain field exceeds a certain number of lines or a certain number of characters that field is not visible and...
22
2501
by: Cogito | last post by:
For the first time, I'm attempting to write a small Javascript program using one on the online reference sites. I need some confirmation as to the behaviour of the break statement. In the...
9
3327
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. I have a class with an collection property. The collection property is sometimes equal to nothing. The class has a function named 'Exists' which returns TRUE if the specified string exists...
1
368
by: Walt | last post by:
Hi, I want to write a query that returns Y or N depending on whether the current time is within a specified window i.e. EVENT_TABLE ---------- event_id number PK event_start date...
7
14541
by: =?Utf-8?B?Sm9zZXBo?= | last post by:
I would like to know how to implement several Radiobuttons using the Switch statement instead of If/Else conditional statement. For instance, if I have the following: if (RadioButton1.Checked =...
1
5464
ollyb303
by: ollyb303 | last post by:
Hello, I have been using the following expression in Access as part of a statement to query an Oracle database: (Sum(CASE WHEN STATS_DAILY_SA.LOGIN_TIME > (STATS_DAILY_SA.SCHEDULED_TIME -...
0
7138
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7355
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5668
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3213
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1576
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.