(Solved) – VBA Date + TimeValue returns no time


I have a date and time which I assemble into a date time from strings in the form

date_string = "2020-12-30" 'yyyy-mm-dd    
date_code = CDate(date_string)

time_string = "00:00:00" 'hh:mm:ss
time_code = TimeValue(time_string)

date_time = date_code   time_code

Commonly the return looks like 05.01.2019 11:00:00, which is what I expect.

The returned values also all check out as TRUE if I test with IsDate(date_time)

Whenever the time is 00:00:00 however, I only get the date returned with no time appended. I dont quite understand this, since TimeValue(time_string)returns 00:00:00.

So it must be an issue when combining date and time to a date time string.

Can someone please enlighten me why midnight somehow does no exist in Excel VBA or where my error in creating the time code is?

Leave a Reply

Your email address will not be published. Required fields are marked *