Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with syntax 1

Status
Not open for further replies.

cschnable

Programmer
May 24, 2001
36
US
I am trying to generate the day of the week in a query, the following is not working and I don't know why. - Can anyone help me out.


WeekDayText: IIf(([DayCalc]=1,"Sunday"),IIf(([DayCalc]=2,"Monday"),IIf(([DayCalc]=3,"Tuesday"),IIf(([DayCalc]=4,"Wednesday"),IIf(([DayCalc]=5,"Thursday"),IIf(([DayCalc]=6,"Friday"),"Saturday"))))))



Any help will be appreciated - Thanks
 
What is the data type of DayCalc?
Is this a column you have calculated? If so, how?
 

Try the CHOOSE function rather than IIF.

WeekDayText: CHOOSE ([DayCalc], "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")

The IIF isn't working because the syntax is incorrect. You have too many parentheses. You can use the following corrected IIF statement if you prefer. However, I recommend the CHOOSE function because it is simpler to read and understand.

WeekDayText: IIf([DayCalc]=1,"Sunday",IIf([DayCalc]=2,"Monday",IIf([DayCalc]=3,"Tuesday",IIf([DayCalc]=4,"Wednesday",IIf([DayCalc]=5,"Thursday",IIf([DayCalc]=6,"Friday","Saturday"))))))
Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top