Search notes:

VBA: Extract year, month, day, hour, minute and second as integer from a date

The VBA functions year, month, day, hour, minute and second allow to extract the respective portions from a date as integer.
option explicit

sub main() ' {

    dim dt as date
    dt = now()

    debug.print("Year:   " & year  (dt))
    debug.print("Month:  " & month (dt))
    debug.print("Day;    " & day   (dt))

    debug.print("Hour:   " & hour  (dt))
    debug.print("Minute: " & minute(dt))
    debug.print("Second: " & second(dt))

end sub ' }
Github repository about-VBA, path: /functions/year-month-day-hour-minute-second.bas

See also

Date and time related functions.
The SQL Server functions year(), month() and day()

Index