Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401

    Unanswered: Date+Time = Datetime ?????

    How can you concatenate two date columns .. one contains the date .. other contains the time (ie date is always '1900-01-01' ) ...

    I wan t to get a datetime out of these columns .. how do i do it ???
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    Use the following:

    select cast(cast(date1 as decimal(20,10))+cast(date2 as decimal(20,10)) as datetime) from table

  3. #3
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    Does not Work
    Am providing some Sample data .........
    Start Date Start Time
    2003-06-03 00:00:00.000 1900-01-01 07:00:00.000
    2003-06-02 00:00:00.000 1900-01-01 18:25:00.000
    2003-06-04 00:00:00.000 1900-01-01 03:35:00.000
    2003-06-04 00:00:00.000 1900-01-01 07:00:00.000
    2003-06-03 00:00:00.000 1900-01-01 18:45:00.000
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  4. #4
    Join Date
    Dec 2003
    Posts
    1
    Try This.

    select convert(datetime, date1) + convert(datetime, date2)

    Hope this helps!

    Cheers!

  5. #5
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    Thanks everybody ...
    finally did it myself

    create function concat_date_time(@d1 datetime,@d2 datetime)
    returns datetime
    as
    begin
    return convert(datetime,substring(convert(varchar(23),@d1 ,121),1,10)
    +substring(convert(varchar(23),@d2,121),11,len(con vert(varchar(23),@d2,121))-11),121)
    end
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

Posting Permissions

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