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

Find no of Days in Previous month

100+
P: 106
Hi,

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


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

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

Linq ;0)>
Apr 13 '10 #3

NeoPa
Expert Mod 15k+
P: 31,186
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.