Results 1 to 3 of 3
  1. #1
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6

    Unanswered: Combining date and time

    I have 2 fields, one containing just the date and another containing the time. I want to combine them into a proper date/time format. No matter what I try, I lose 2 days in the process. Combining

    2005-12-21 00:00:00.000
    and
    1899-12-30 14:30:00.000

    will get me the 19th at 14:30. What am I missing here?

    TIA
    Paul

  2. #2
    Join Date
    Dec 2002
    Posts
    1,245
    This was addressed recently in the following thread: link

    Regards,

    hmscott
    Have you hugged your backup today?

  3. #3
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Thank you. I searched and somehow missed that thread. Bad choice of search words I suppose. I guess my problem was not using varchar. I had tried using convert but used datetime as the type, using a style of 101 for the date portion and 108 for the time. This seems to be working correctly:

    Convert(datetime,Convert(varchar(11), DateField, 101) + ' ' + Convert(varchar(8), ReqTime, 108))
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •