FAQ Database Discussion Community


SQL IF Statement With dates

sql,date,ms-access,ms-access-2013,iif
So I can not seem to enter date or IIF Statement without syntax errors! SELECT iif ([hire_date] = <'#2000-01-01#','Old Gaurd') From L_employees I need to write a IIF statement that checks if [Hire_Date] is before the year 2000 then replace it with OLD PROS, otherwise Young GUNS....

.NET use IIF to assign value to different variables

.net,vb.net,conditional,variable-assignment,iif
Could I (and if so how) do the following in .NET language (more specifically VB.NET): Dim a,b as Integer if(somecondition=1,a,b) = 12345 Or any variant with IIF would be fine by me. Basically I'm always assign the same value but never to the same variable.....

SSRS conditional formatting (Using AND and OR)

algorithm,reporting-services,ssrs-2008,conditional-formatting,iif
I have a question regarding a complicated conditional formatting that I currently trying to put in place. The code is: =iif(Fields!ACT.Value = "N/V", "No Color", iif(Fields!ACT.Value = "N/K", "No Color", iif(Fields!ACT.Value = "N/A", "No Color", iif(Fields!NUM.Value < Fields!SHORT.Value , "Yellow", iif(Fields!NUM.Value > Fields!INC.Value, "Orange", iif((isnothing(Fields!ACT.Value <> "N/A" and Fields!NUM.Value) or...

Query for date range based on day of the week

sql,date,ms-access,iif
I'm trying to make a query that presents records from the current day and the day before, but if its a Monday, display the records from the whole weekend as well as the current day. The logic works, however I can't get date ranges working. I can get singular dates...

Access expressions in table

ms-access,switch-statement,iif
I would collect my IIF or switch expressions in a table as a record(more over 40pcs): tbl_filter: Filter Description LIKE '*SCREW*',"Screw" Description LIKE '*SOCKET*',"SScrew" How could I use this expression-collection in tbl_filter in a switch function in a query? similar like this: SELECT Item, switch(Select * from tbl_Filter) AS Cathegory...

report builder IIF() function with multiple TRUE value

reporting-services,ssrs-tablix,reportbuilder,iif
I'm encountering an issue while develloping some report on RB. I have a tablix that where the columns are the hours of the day, and the rows are different products. I also have a parameter with 3 values (AM, PM, NIGHT). The point here is that if the parameter is...

Using LIKE in Count(IIF()) in MS Access, get NA count

sql,ms-access,ms-access-2013,iif
I'm attempting to get a count of NAs in a field in a table in MS Access. I have multiple NAs: #N/A* (i.e. NAs that start with hash & "N/A" & some more text that varies.) NaN NA N/A (They all mean something different for us, so it i actually...

Using IIF function in OPENQUERY

sql-server,dynamic-sql,linked-server,iif,openquery
Declare @OPENQUERY nvarchar(500), @TSQL nvarchar(max), @LinkedServer nvarchar(20), @PickedDate varchar(8) Set @LinkedServer = 'LinkedServerName' Set @OPENQUERY = 'Select * From Openquery('+ @LinkedServer + ',''' Set @TSQL = 'SELECT sum(iif(left(code,1)=''''C'''', 1, 0) As ActiveCases From cases Where cases.date_opened = ''''' + @vcPickedDate + ''''' '')' Exec (@[email protected]) When I ran this query,...

List box and Option group filtering 3 different rows in MAIN list box in MS Access 2013

ms-access,filter,ms-access-2013,query-builder,iif
I've been struggling with the following for a while and would be more than happy for some brainpower ;) I have an Advanced filter form, which filters through orders via many different filters, currently the one that I can't make function is the following: I have 4 controls on a...

How to use mixed int and numeric arguments in a Postgres 9.1+ function

sql,postgresql,parameter-passing,plpgsql,iif
I'm looking for a way to create an icase() function which works with any second and third parameter compatible data types. I tried in Postgres 9.4: CREATE OR REPLACE FUNCTION public.icase( cond1 boolean, res1 anyelement, conddefault anyelement) RETURNS anyelement AS ' SELECT CASE WHEN $1 THEN $2 ELSE $3 END;...