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!

LOOPING day in month by year 1

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
422
IT
Admit have MyVarYear=2020

how to looping all date days in the 12 month...

pseudo code

first month
01/01/2020
02/01/2020
...
31/01/2020
second month
01/02/2020
02/02/2020
...
29/02/2020

ecc....

 
OK, I had a few minutes to kill...

Provide your own [red]Year[/red] and [red]Month[/red]:

Code:
Const intYear As Integer = [red]2020[/red]
Const intMonth As Integer = [red]1[/red]
Dim intD As Integer
Dim dat As Date

intD = 1

dat = DateSerial(intYear, intMonth, intD)

Do While Month(dat) = intMonth
    Debug.Print dat & " -- " & Format(dat, "Long Date")
    intD = intD + 1
    dat = DateSerial(intYear, intMonth, intD)
Loop

Debug.Print "  ***  I am done, happy now?  ***"


---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top