Set a date at the beginning of the month
By: Lorenzo Dalla Vecchia Date: 25/06/2000

Basing on a date variable, the following code returns the date at the beginning of the month.

Dim D As Date
Dim
D1 As Date

D = "given date"
D1 = DateAdd("d", (Day(D) - 1) * -1, D)

'D1 will contain date at the beginning of the month

Replace "given date" with a valid date. For example:

Dim D As Date
Dim
D1 As Date

D = "25/06/2000"
D1 = DateAdd("d", (Day(D) - 1) * -1, D)

'D1 will contain "01/06/2000"

 

Click Here!


Visual Basic Programming Zone is a website by Lorenzo Dalla Vecchia.
To contact the Webmaster, click here.
Hosted by InWind: www.inwind.it