Combining Date/Time

W

Welthey

Currently I have a date and a time field in my table. I need to be able to
combine these two items into one field, but when I try to combine them it is
subtracting 2 days off of the actual date. My table is in SQL. Is there any
way around this, this is the code that I am using

update dbo.purgedrecords
Set [datetime] = AuthDate + convert(datetime, AuthTime)

Previously this was working when the default date on the time was 01/01/1900
and then somehow something changed and the default date is now showing as
12/30/1899. Is there different code that I can use to keep this from
happening in the future?
 
A

Arvin Meyer [MVP]

The default, zero date is 12/30/1899. Time vales are on the decimal side, so
you are string to add:

0.25 to your current date, and the value is being read as:

12/30/1899 6:00 AM

Try converting both values to a string and concatenating the time to the
date, then converting back to a date.
 
D

Douglas J. Steele

Those dates you quote (01/01/1900 and 12/30/1899) make it sound as though no
value is actually getting assigned to AuthDate (1 Jan, 1900 is the "base
date" in SQL server, while 30 Dec, 1899 is it in Access)

That having been said though, I don't believe it's necessary to use the
Convert function. Dates and times are stored as numeric values: I believe
you can simply add AuthDate + AuthTime.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top