A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Combining Date/Time



 
 
Thread Tools Display Modes
  #1  
Old October 30th, 2008, 12:51 PM posted to microsoft.public.access
Welthey
external usenet poster
 
Posts: 52
Default Combining Date/Time

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?


  #2  
Old October 30th, 2008, 01:52 PM posted to microsoft.public.access
Arvin Meyer [MVP][_2_]
external usenet poster
 
Posts: 2,310
Default Combining Date/Time

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.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


"Welthey" wrote in message
...
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?




  #3  
Old October 30th, 2008, 01:54 PM posted to microsoft.public.access
Al Campagna[_2_]
external usenet poster
 
Posts: 1,462
Default Combining Date/Time

Welthey,
Try just AuthDate + AuthTime.
1/1/08 = 39448.00000
12:00 PM = .5000000
-------------------------------
39448.500000 = 1/1/08 12:00 PM

--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

"Welthey" wrote in message
...
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?




  #4  
Old October 30th, 2008, 01:54 PM posted to microsoft.public.access
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Combining Date/Time

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.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Welthey" wrote in message
...
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?




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:07 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.