inglesp
inglesp

Reputation: 3357

Date Component Manipulation

Is it possible to manipulate the components, such as year, month, day of a date in VBA? I would like a function that, given a day, a month, and a year, returns the corresponding date.

Upvotes: 3

Views: 1632

Answers (3)

Prestaul
Prestaul

Reputation: 85224

You want DateSerial:

Dim someDate As Date = DateSerial(year, month, day)

Upvotes: 2

Swati
Swati

Reputation: 52847

DateSerial(YEAR, MONTH, DAY)

would be what you are looking for.

DateSerial(2008, 8, 19) returns 8/19/2008

Upvotes: 6

Nescio
Nescio

Reputation: 28443

There are several date functions in VBA - check this site

DateSerial(YEAR, MONTH, DAY)

Upvotes: 2

Related Questions