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.
2 1314
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 - SELECT Table1.ThisDate
-
FROM Table1
-
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))
-
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
You could try this - SELECT Table1.ThisDate
-
FROM Table1
-
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))
-
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 ? - SELECT ThisDate
-
FROM Table1
-
WHERE ThisDate=Date()-1 Or ThisDate=IIf(Weekday(Date())=2,Date()-2,Date()-1) Or ThisDate=IIf(Weekday(Date())=2,Date()-3,Date()-1)
-
ORDER BY ThisDate;
-
??
MTB
Sign in to post your reply or Sign up for a free account.
Similar topics
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,...
|
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...
|
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...
|
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...
|
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...
|
by: sassy |
last post by:
.....how can i incorporate videos on website using flash??
|
by: jakorando |
last post by:
describe the steps followed to incorporate an ActiveX components in visual basic
|
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...
|
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...
|
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
|
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...
|
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...
|
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,...
|
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,...
|
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...
|
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...
|
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...
|
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,...
| |