Real quick question. I'm trying to set a default value in an Access table that gives me today's date and 8AM as the time.
I attempted to use =Date() & "8:00:00 AM"
but I am getting a type mismatch error. I changed the format of the column to General Date to be able to have date and time but still no go.
Any help would be greatly appreciated.
CodePudding user response:
You were nearly there. A date isn't a string, so you add time with
and delimit with #
:
=Date() #8:00:00 AM#
Of course, building with parts is fine too but a little too overcomplicated imo
CodePudding user response:
You could build the desired date like that
dt = Date
dt = DateSerial(Year(dt), Month(dt), Day(dt))
dt = dt TimeSerial(8, 0, 0)
A date is a number, 2020/02/08 is 44600. A time is a fraction, 8am is 0,333333333333333. If you want to build a date like Today 8 am you need to use the build-in functions Dateserial and Timeserial which gives you excatly the date you need.