I am trying to run a query that will generate a fiscal year based on a date in a table (called fin_month). If the month portion of the date selected is between 10 and 12, I need the year to be +1 (goverment fiscal year). If the month portion is between 1 and 9, then I just need the year. I've put the following string together that I think should work...
Fiscal_Year: iif(datepart("M", [fin_month]) >= 10, datepart("yyyy", [fin_month])+1, datepart(yyyy", [fin_month]))
But, when I click off of the field line in the query, Access is automatically changing the format of the statement to the following...
Fiscal_Year: IIf(DatePart(["M"],[fin_month])>=10,DatePart(["yyyy"],[fin_month])+1,DatePart(["yyyy"],[fin_month]))
Notice the [] being put around the portion of the datepart. This is causing the query to not run correctly. Can anyone suggest a solution to this or why Access is inserting these brackets?
Fiscal_Year: iif(datepart("M", [fin_month]) >= 10, datepart("yyyy", [fin_month])+1, datepart(yyyy", [fin_month]))
But, when I click off of the field line in the query, Access is automatically changing the format of the statement to the following...
Fiscal_Year: IIf(DatePart(["M"],[fin_month])>=10,DatePart(["yyyy"],[fin_month])+1,DatePart(["yyyy"],[fin_month]))
Notice the [] being put around the portion of the datepart. This is causing the query to not run correctly. Can anyone suggest a solution to this or why Access is inserting these brackets?