Date Component Manipulation
Question
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.
Solution
DateSerial(YEAR, MONTH, DAY)
would be what you are looking for.
DateSerial(2008, 8, 19)
returns 8/19/2008
OTHER TIPS
There are several date functions in VBA - check this site
DateSerial(YEAR, MONTH, DAY)
You want DateSerial:
Dim someDate As Date = DateSerial(year, month, day)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow