473,396 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Try to incorporate Or into an IIF statement

1
Hey there all, new here, so go easy...

I am trying to work out this situation.

For a day to day database, show me all records, where if it is Monday today, I want to see Friday, Saturday and Sunday, otherwise I want to see yesterday only.

Trying to write this in Access in the QBE grid.

So far I have come up with:

IIf(WeekdayName(Weekday(Date()),True,1)="Mon",(Dat e()-1 Or Date()-2 Or Date()-3),Date()-1)

Trouble is, if the day is Monday, this returns nothing.

What bugs me is that: ()-1 Or Date()-2 Or Date()-3 by itself does infact return Fri, Sat, Sun.


What am I doing wrong in the IIF statement that if the 3 dates are needed, it doesn't work?

Cheers,

Malc.
Nov 8 '07 #1
2 1314
MikeTheBike
639 Expert 512MB
Hey there all, new here, so go easy...

I am trying to work out this situation.

For a day to day database, show me all records, where if it is Monday today, I want to see Friday, Saturday and Sunday, otherwise I want to see yesterday only.

Trying to write this in Access in the QBE grid.

So far I have come up with:

IIf(WeekdayName(Weekday(Date()),True,1)="Mon",(Dat e()-1 Or Date()-2 Or Date()-3),Date()-1)

Trouble is, if the day is Monday, this returns nothing.

What bugs me is that: ()-1 Or Date()-2 Or Date()-3 by itself does infact return Fri, Sat, Sun.


What am I doing wrong in the IIF statement that if the 3 dates are needed, it doesn't work?

Cheers,

Malc.
Hi

You could try this
Expand|Select|Wrap|Line Numbers
  1. SELECT Table1.ThisDate
  2. FROM Table1
  3. WHERE Weekday([ThisDate])=Weekday(Date())-1 Or Weekday([ThisDate])=IIf(Weekday(Date())=2,Weekday(Date())-2,Weekday(Date()-1)) Or Weekday([ThisDate])=IIf(Weekday(Date())=2,Weekday(Date())-3,Weekday(Date()-1))
  4. ORDER BY Table1.ThisDate;
Weekday() is a function that return a number for th day of the week entered.
The default is 1=Sunday, 2 = Monday etc. (this can be changes with an optional argument, try looking at the Access Help.

There are probably better solutions that this but have to stop somewhere !?

MTB
Nov 8 '07 #2
MikeTheBike
639 Expert 512MB
Hi

You could try this
Expand|Select|Wrap|Line Numbers
  1. SELECT Table1.ThisDate
  2. FROM Table1
  3. WHERE Weekday([ThisDate])=Weekday(Date())-1 Or Weekday([ThisDate])=IIf(Weekday(Date())=2,Weekday(Date())-2,Weekday(Date()-1)) Or Weekday([ThisDate])=IIf(Weekday(Date())=2,Weekday(Date())-3,Weekday(Date()-1))
  4. ORDER BY Table1.ThisDate;
Weekday() is a function that return a number for th day of the week entered.
The default is 1=Sunday, 2 = Monday etc. (this can be changes with an optional argument, try looking at the Access Help.

There are probably better solutions that this but have to stop somewhere !?

MTB
Hi

Having reflected overnight I decided there was a flaw in the las query suggesed, I think this will do what is required ?
Expand|Select|Wrap|Line Numbers
  1. SELECT ThisDate
  2. FROM Table1
  3. WHERE ThisDate=Date()-1 Or ThisDate=IIf(Weekday(Date())=2,Date()-2,Date()-1) Or ThisDate=IIf(Weekday(Date())=2,Date()-3,Date()-1)
  4. ORDER BY ThisDate;
  5.  
??

MTB
Nov 9 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Sans Spam | last post by:
Greetings! I have a table that contains all of the function permissions within a given application. These functions are different sections of a site and each has its own permissions (READ, WRITE,...
0
by: Michel | last post by:
I was successfully able to compile and incorporate an HTML Help file into my Access database. However, the only way that I was able to do this was by repeating the name of the HTML Help file...
1
by: Javier Estrada | last post by:
I have a source-code library, that provides header and source files (similar to MFC). What would be a good way to automatically incorporate it into other projects? The way I do it today is by...
11
by: Kevin | last post by:
I have a problem I'm trying to figure out how to resolve in Access. I have a volunteer database for a project which occurs each year. Currently I have to go in and wipe out the data each year to...
2
by: Charles Wilt | last post by:
I have a IBM iSeries (aka AS-400) running v5r3 of OS/400 that I access via a linked server from SQL Server 2000. The following select works fine: select * from...
1
by: sassy | last post by:
.....how can i incorporate videos on website using flash??
1
by: jakorando | last post by:
describe the steps followed to incorporate an ActiveX components in visual basic
1
by: Cage26 | last post by:
First, I need to rewrite the program to incorporate functions. And there should be a value returning function that returns an int that the user entered. It will be called 5 times, once for each...
1
by: olseni | last post by:
Hi all I dont know if anyone can answer this, but is it possible to incorporate uploaded attachments, ie pdf files, into an access report. Ie if I have a normal access report, but would like to add...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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
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...
0
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,...

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.