Alegro
Alegro

Reputation: 7956

How to set the Day of Date?

Dim dt1 As Date
dt1 = Date
MsgBox dt1 ' works - 12.10.2012
Day(dt1) = 1 ' error: object required

I need 1.10.2012
So, for any date, I need to set dt1 as first day of that specific date.

Upvotes: 3

Views: 4924

Answers (2)

Alex K.
Alex K.

Reputation: 175748

You could also deduct the days directly

dt1 = dt1 - Day(dt1) + 1

Upvotes: 3

user857521
user857521

Reputation:

You could use dateserial to reconstruct a date

eg

newDate = DateSerial(Year(dt1), Month(dt1), 1)

Upvotes: 7

Related Questions