473,587 Members | 2,548 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.e vent_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 23271

Try this:

...
decode(sign(sys date-event_start),-1,'N'
,decode(sign(ev ent_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
2262
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 Postgraduate. And I have programmed some REXX applications in my past Jobs (So I love python, no more ENDS). ** Reposting from Python-Dev with some...
3
1725
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 write an if statement so that if: 1. The word "Month" is in the validFromMonth field (where they haven't selected a month a the drop-down menu)...
11
14273
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 was received is then sent to the http://validator.w3.org website to validate your HTML / XHTML. So far I've got everything to work, even the part...
4
9184
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 another field on a second page becomes visible. Following is my "If Statement" that doesn't work. My issue is how to refer to the number of lines or...
22
2520
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 following code: for ( row = 0 ; row <= 7 ; row++ ) A <---- { for ( col = 0 ; col <=7 ; col++ ) B <---- {
9
3333
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 in the collection, and FALSE if it does not. This is illustrated below. My co-worker and I are having a friendly disagreement as to whether or not...
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 event_end date
7
14565
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 = true) { //Do something; } elseif(RadioButton2.Checked = true) {
1
5479
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 - DECODE(STATS_DAILY_SA.EXCEPTION_TIME, Null, 0, STATS_DAILY_SA.EXCEPTION_TIME)) THEN 0 ELSE ((STATS_DAILY_SA.SCHEDULED_TIME -...
0
7849
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8347
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7973
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6626
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5718
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5394
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3844
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.