date count

M

manolakshman

How do you count the number of days in a month without giving the start date
and end date. As everyone knows jan has 31 days, how do u get this info as
simple as it is from access
 
R

rico

Given the input of any date (txtDate), these two functions, first get the
start date of the month, then days in that month:

dteStartDate = txtDate - Day(txtDate) + 1
intDays = Day(DateAdd("m", 1, dteStartDate) - 1)

Taken from Allen Browne's date picker.

HTH

Rico
 
J

John Spencer

Given any date the following expression will return the number of days in the
month.

Day(DateSerial(Year([DateValue]),Month([DateValue)+1,0)

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
K

Keith Wilby

John Spencer said:
Given any date the following expression will return the number of days in
the month.

Day(DateSerial(Year([DateValue]),Month([DateValue)+1,0)

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

What a brilliant little expression John, I've added it to my library -
thanks! There seem to be a couple of typos, this example works for me:

Day(DateSerial(Year([DateValue]),Month([DateValue])+1,0))

Regards,
Keith.
 
M

manolakshman

Thanks John and Keith. It really works


Keith Wilby said:
John Spencer said:
Given any date the following expression will return the number of days in
the month.

Day(DateSerial(Year([DateValue]),Month([DateValue)+1,0)

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

What a brilliant little expression John, I've added it to my library -
thanks! There seem to be a couple of typos, this example works for me:

Day(DateSerial(Year([DateValue]),Month([DateValue])+1,0))

Regards,
Keith.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top