|
-
August 19th, 1999, 11:33 AM
#1
Dates
Is there a method in VB if I pass in a month and year it will tell me the number of days in the month?
-
August 26th, 1999, 01:24 PM
#2
Re: Dates
Well I have a vague idea that it can be done using the calendar property.
Declare a variable as calendar and then try.I hope you can find your way out!!!
-
August 26th, 1999, 03:59 PM
#3
Re: Dates
You need to look at the 'DateDiff' function in VB (in the help). Here's a quick example :
Dim dteStartDate as date
Dim dteEndDate as date
dteStartDate = CDate("01 Feb 1999") ' could use #2/1/1999
dteEndDate = CDate("01 Mar 1999") ' could use #3/1/1999
MsgBox DateDiff("d", dteStartDate, dteEndDate)
This shows the number of days between the two dates (and hence in the month).
Chris Eastwood
CodeGuru - the website for developers
http://www.codeguru.com/vb
-
August 30th, 1999, 03:01 AM
#4
Re: Dates
A simple way to implement this is to move to the 1st of the next month and -1 a day to find the max nos of days this month using the dateadd function.
Ex : =
curr_dt = '1/9/99'
last_DATE = DateAdd("D", -1, (DateAdd("M", 1, curr_dt)))
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|