Hi, I am trying to figure out how to create a field in my query that calculates the number of days in the previous month. I have been trying to use the DateSerial function, but can't get it to work. Does anyone have any suggestions?
Kirsti
Hi, I am trying to figure out how to create a field in my query that calculates the number of days in the previous month. I have been trying to use the DateSerial function, but can't get it to work. Does anyone have any suggestions?
Kirsti
What I have so far is:
DateDiff(“d”,DateSerial(Year(Now()),Month(Now()),1-1),DateSerial(Year(Now()),Month(Now())-1,1))
But when I try and run it, I get 'Enter Parameter Value "d"'
Strangely, when I went into the SQL view of the query and ran it, it ran without the 'Enter Parameter Value' error, and now it runs perfectly from any view.
So, I have what I want!
One way could perhaps be :
Another way, get the Last & 1st Date of the previous month & then use DateDiff().Code:SELECT DateSerial(Year(Date()),Month(Date()),1)-1 AS TheLastDayOfThePreviousMonth, DatePart("d",[TheLastDayOfThePreviousMonth]) AS TheNoOffDays;
Edit : My typing speed.
Thanks