Results 1 to 3 of 3

Thread: Combination of Date and Time Column in SQL

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    240

    Combination of Date and Time Column in SQL

    I was tasked to create a system from an existing system. The old system database table is shown below:


    Code:
    Date                                Time                              ID
    5/4/2009 00:00:00           1899/12/30 07:55:30         84321
    How can I query the above example to something like this?

    Code:
    DateTime                               ID
    5/4/2009 07:55:30                 84321
    I try to do this using this query:

    Code:
    select Date + Time as 'DateTimeRecord', ID from transdata
    But unfortunately the result is this:

    Code:
    DateTime                               ID
    5/2/2009 07:55:30                 84321
    Last edited by jsc0624; Jun 22nd, 2009 at 03:29 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Combination of Date and Time Column in SQL

    What you are getting looks to me like exactly what you are asking for so I can't be clearly understanding the problem.

  3. #3
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,495

    Re: Combination of Date and Time Column in SQL

    Look at using Convert, Convert to Varchar for the date portion getting just the date, then again for the time portion getting just the time. Contact the two pieces together then convert all back to a datetime.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

Posting Permissions

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



Click Here to Expand Forum to Full Width