<% if month(FP_FieldVal(fp_rs,"SickDay1")) AND year(FP_FieldVal(fp_rs,"SickDay1")) = varDS Then%><%=FP_FieldVal(fp_rs,"SickDay1")%><%end if%>
<% if month(FP_FieldVal(fp_rs,"SickDay2")) AND year(FP_FieldVal(fp_rs,"SickDay2")) = varDS Then%><%=FP_FieldVal(fp_rs,"SickDay2")%><%end if%>
<% if month(FP_FieldVal(fp_rs,"SickDay3")) AND year(FP_FieldVal(fp_rs,"SickDay3")) = varDS Then%><%=FP_FieldVal(fp_rs,"SickDay3")%><%end if%>
I have a table with columns called sickday1, sickday2 and sickday3. I am sending the statement a variable called varDS. varDS is always going to be a date.
varDS = 2008-03-01
sickday1 = 2008-04-01
sickday2 = 2008-05-01
sickday3 = 2008-03-01
Using the above IF statement I thought that it would just return the sickday3 field because the month and year in sickday3 matched varDS.
Unfortunately it returns all 3 columns from the row because one of them matched. Is it possible to pull only the column from the row that matches.
Here is the SQL for it as well
SELECT `sick`.`ID`,`sick`.`StartSickDay`,`sick`.`EndSickDay`,`sick`.`SickDay1`,`sick`.`SickDay2`,`sick`.`SickDay3`,`sick`.`DateEntered`,`users`.`UserName` FROM `sick` Inner Join `users` ON `sick`.`UserID` = `users`.`UserID` WHERE(month(`sick`.`StartSickDay`) = month(' " & varDS & " ') OR month(`sick`.`EndSickDay`) = month(' " & varDS & " ') OR month(`sick`.`SickDay1`) = month(' " & varDS & " ') OR month(`sick`.`SickDay2`) = month(' " & varDS & " ') OR month(`sick`.`SickDay3`) = month(' " & varDS & " ') ) AND (year(`sick`.`StartSickDay`) = year(' " & varDS & " ') OR year(`sick`.`EndSickDay`) = year(' " & varDS & " ') OR year(`sick`.`SickDay1`) = year(' " & varDS & " ') OR year(`sick`.`SickDay2`) = year(' " & varDS & " ') OR year(`sick`.`SickDay3`) = year(' " & varDS & " ') ) AND users.UserName = '" & varUN & "'"
Much appreciated!