PC Review


Reply
Thread Tools Rate Thread

Combining Date/Time

 
 
Welthey
Guest
Posts: n/a
 
      30th Oct 2008
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?


 
Reply With Quote
 
 
 
 
Arvin Meyer [MVP]
Guest
Posts: n/a
 
      30th Oct 2008
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" <(E-Mail Removed)> wrote in message
news:B4AFF99A-20AB-4845-918C-(E-Mail Removed)...
> 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?
>
>



 
Reply With Quote
 
Al Campagna
Guest
Posts: n/a
 
      30th Oct 2008
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" <(E-Mail Removed)> wrote in message
news:B4AFF99A-20AB-4845-918C-(E-Mail Removed)...
> 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?
>
>



 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      30th Oct 2008
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" <(E-Mail Removed)> wrote in message
news:B4AFF99A-20AB-4845-918C-(E-Mail Removed)...
> 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?
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining date and time data Nathan Microsoft Excel Worksheet Functions 3 15th Jul 2008 06:28 PM
Combining date and time into one cell =?Utf-8?B?S2VsbHkgQw==?= Microsoft Excel Misc 3 9th Jul 2008 09:27 PM
Combining a date value with a time value Aussie Rules Microsoft VB .NET 6 27th Sep 2006 03:41 AM
Combining date and time in order to get the difference rantz Microsoft Excel Discussion 19 9th Dec 2005 09:41 AM
Combining Time and Date =?Utf-8?B?VHJpYWwgJiBFcnJvcg==?= Microsoft Access Database Table Design 1 18th Apr 2005 03:05 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:34 PM.