By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,466 Members | 1,167 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,466 IT Pros & Developers. It's quick & easy.

Find no of Days in Previous month

P: 106

I need help to create an sql command to find no of days in the current month of calculation and no of days in the month previous to it.

This code works for the current month, but only because mgmtstart is always 1st of the month.

Expand|Select|Wrap|Line Numbers
  1. DaysinMonth: DateDiff("d",[mgmtDateStart],DateSerial(Year([mgmtdatestart]),Month([mgmtdatestart])+1,1))
your help is greatly appreciated.
Apr 13 '10 #1

✓ answered by missinglinq

DaysInPreviousMonth:Day(DateSerial(Year(Date), Month(Date), 0))

Linq ;0)>

Share this Question
Share on Google+
3 Replies

P: 320
I believe Access has a DateAdd() function. I think this is what you want.
Apr 13 '10 #2

Expert 2.5K+
P: 3,532
DaysInPreviousMonth:Day(DateSerial(Year(Date), Month(Date), 0))

Linq ;0)>
Apr 13 '10 #3

Expert Mod 15k+
P: 31,768
And, by extension :
Expand|Select|Wrap|Line Numbers
  1. DaysInMonth: Day(DateSerial(Year(Date), Month(Date) + 1, 0))
Apr 13 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.