Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Initializing DTPicker with end of month value 2

Status
Not open for further replies.

new2unix

Programmer
Feb 5, 2001
143
US
Hi,

Need some help in the proper VB statements to initialize the DTPicker upon Form_Load. Since the end of month may be different from month to month depending on the month and the current year. What would be the proper VB statements to use to initialize the DTPicker value as the end of the current month?

Thanks,

Mike
 

To get the last day of the current month...

dtLastDayOfMonth = DateSerial(Year(Now()),Month(Now()) + 1, 0)

 
Just use the fact the the day zero of next month is the last day of this month:
Code:
DTPicker1.Value = DateSerial(Year(Date), Month(Date) + 1, 0)

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
I gave you both a star. A simple and elegant answer. Not knowing about the 0th day of the month, I would have gotten the first day to the next month and then use datadd function to subtract 1 day.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top