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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set End and Begin Dates

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
<br>Hi<br>I need help in setting a begindate (which is calling for GetDate and the first of that month) and the enddate (again getdate and end of that month)<br>I am going to be running this for a year(12 times). But my problem is setting the dates. Pls help....
 
If you want to know the first day of the Month its simply <br>yearnum = ' The year you want<br>monthnum = the MOnth you want<br>FirstOfMonth= Dateserial (Year(yearnum),Month(monthnum),1)<br>LastOfMonth = DateSerial(Year(yearnum), Month(monthnum) + 1, 1-1)<br><br>If you want curent info then<br>FirstOfMonth= Dateserial (Year(now),Month(now),1)<br>LastOfMonth = DateSerial(Year(now), Month(now) + 1, 1-1)<br><br><br>Put it all in a &quot;for next&quot; loop<br><br>Public Function test()<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim a As Integer<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim FirstOfMonth, LastOfMonth As Date<br>&nbsp;&nbsp;&nbsp;&nbsp;For a = 1 To 12<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FirstOfMonth = DateSerial(Year(Now), a, 1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LastOfMonth = DateSerial(Year(Now), a + 1, 1 - 1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Debug.Print FirstOfMonth, LastOfMonth<br>&nbsp;&nbsp;&nbsp;&nbsp;Next<br>End Function<br><br>OK<br><br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top