ghudson
Registered User.
- Local time
- Today, 06:41
- Joined
- Jun 8, 2002
- Messages
- 6,195
Can you tell why this is not working? I cannot get my IIF statement to work in the criteria of my query with the between dates I am using in my IIF. When I use the true or false parts by themselves, the criteria works in the query but I get no results when I use the IIF as listed below. This does test correctly to determine if the current month is January or not... IIf(Month(Date())=1,"TRUE","FALSE")
I am trying to build the date criteria for a query and I need to determine the first and last day of the current year and the first and last day of the previous year. Basically I have to use last years dates if the current month is January when the query is run or else use the current years dates if the query is run during any month other than January.
Anybody see what needs to be tweaked for my IIF in my query to use the correct dates between criteia? Did I goof and leave something out? Thanks!
I know the DateSerials I have constructed work for his my proof.
I am trying to build the date criteria for a query and I need to determine the first and last day of the current year and the first and last day of the previous year. Basically I have to use last years dates if the current month is January when the query is run or else use the current years dates if the query is run during any month other than January.
Anybody see what needs to be tweaked for my IIF in my query to use the correct dates between criteia? Did I goof and leave something out? Thanks!
Code:
IIf(Month(Date())=1,Between DateSerial(Year(Date())-1,1,1) And DateSerial(Year(Date()),Month(12),0),Between DateSerial(Year(Date()),1,1) And DateSerial(Year(Date())+1,Month(12),0))
I know the DateSerials I have constructed work for his my proof.
Code:
'1/1/2009
MsgBox "First day of previous year = " & DateSerial(Year(Date) - 1, 1, 1)
'12/31/2009
MsgBox "Last day of previous year = " & DateSerial(Year(Date), Month(12), 0)
'1/1/2010
MsgBox "First day of current year = " & DateSerial(Year(Date), 1, 1)
'12/31/2010
MsgBox "Last day of current year = " & DateSerial(Year(Date) + 1, Month(12), 0)