hey guys,
I want to do some mathwork in a MS access query. But i tried a couple of syntax to get this to work but i can quite get my condition translated for a MS access querry Can someone tell me how i get get two IF conditions into the query.
My psudo-code is as follows -
iF (Priority='AOG')
-
if (Service = 'D2D')
-
timeA = time2-time1
-
else
-
timeA = time3-time1
-
else
-
if (Service = 'D2D')
-
timeA = time2-time4
-
else
-
timeA = time5-time4
-
Assuming you have all the fields specified available, then you would need to use the IIf() function. In this case it would have to be stacked : - timeA: IIf([Priority]='AOG',
-
IIf([Service]='D2D',[time2]-[time1],[time3]-[time1]),
-
IIf([Service]='D2D',[time2]-[time4],[time5]-[time4]))
Welcome to Bytes!
PS. Linq brings up an important point about dealing with dates & times. I cannot guarantee your maths will work. I only duplicate what you already had to illustrate the structure of the instruction.
3 3295
I think that first off we need to know what kind of Datatypes are we dealing with here. Are Time1, Time2, TimeA, etc. actual Date/Time fields, as their names imply, or something else, such as Numbers or Text? If Date/Time fields, do they contain Date and Time or just Time?
Or are these Lapsed Times, i.e. hours, minutes, seconds?
All these things make a difference in how you do 'math' with 'times.'
Welcome to Bytes!
Linq ;0)> NeoPa 32,556
Expert Mod 16PB
Assuming you have all the fields specified available, then you would need to use the IIf() function. In this case it would have to be stacked : - timeA: IIf([Priority]='AOG',
-
IIf([Service]='D2D',[time2]-[time1],[time3]-[time1]),
-
IIf([Service]='D2D',[time2]-[time4],[time5]-[time4]))
Welcome to Bytes!
PS. Linq brings up an important point about dealing with dates & times. I cannot guarantee your maths will work. I only duplicate what you already had to illustrate the structure of the instruction.
Thanks guys!!!
It worked...the "times" were formatted as date/time... did some minor *24 etc manipulations to get the result int he desired output... the main problem i had was in the double IF conditions :)
Thanks again!!!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: david liu |
last post by:
access 2000 query:
here's what i want to do. from an asp page, perform a search on a
table in access. i have used sql code in the asp page itself, but i'd
rather execute a query in access. i...
|
by: Art |
last post by:
Hi,
Can anyone point me to an example of how I would execute a query I've created in an Access DB. I've copied the SQL down to my VB.net application and that works fine, but it's ugly. I'd like...
|
by: s_wadhwa |
last post by:
SELECT DISTINCTROW "01C" AS dummy, Buildings.BuildingNumber,
UCASE(Buildings.BuildingName) AS BuildingName,
Buildings.MasterPlanCode, Buildings.UniformBuildingCode,...
|
by: ShastriX |
last post by:
Getting a weird error while trying out a query from Access 2003 on a
SQL Server 2005 table.
Want to compute the amount of leave taken by an emp during the year.
Since an emp might be off for...
|
by: zwasdl |
last post by:
Hi,
I'm using MS Access to query against Oracle DB via ODBC. Is it
possible to use HINT in Access?
Thanks,
Wei
|
by: mrkselm |
last post by:
Hi,
I am stuck with a problem in MS Access which does not occur in SQL
Server and I have been banging my head against the wall for a couple of
days now trying to resolve it. Namely, when I...
|
by: =?Utf-8?B?bXNjZXJ0aWZpZWQ=?= |
last post by:
Has anyone successfully used an Access query from .NET? I am trying to do
this and am getting a weird error. .NET calls queries 'stored procedures'.
The error I am getting says "Schema could not be...
|
by: k-man |
last post by:
Hi:
I have an MS Access query for a table called MyTable. One of my
fields in the query is a custom field that looks like "MyField: =
MyFunction(ID)" where ID is a field in MyTable.
I have...
|
by: rahuldev999 |
last post by:
Hi
Can anyone please convert the below access query to the equivalent stored procedure.No problem with the IIF() function but the condition in the "where" clause making problem.so please put some...
|
by: jsacrey |
last post by:
Hey everybody, got a secnario for ya that I need a bit of help with.
Access 97 using linked tables from an SQL Server 2000 machine.
I've created a simple query using two tables joined by one...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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: 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...
|
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,...
| |