Convert from DATETIME to DATE

  • I have a Source column as DATE TIME datatype and I want to update the destination table column only with the DATE.

    Source table : T1

    Source Column (date time data type) : CallStart

    Destination table: T2

    Destination column: (DATE datatype) : Calldate

    I am trying to use convert but i am facing an error.

    Plz help me with this Query.

    thanks

  • show us your query; what part is failing? what specific error are you getting?

    are you using CONVERT(DATE,Yourdatetimefield)?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Update T2

    Set CallDate = ( select CallStart

    from T1

    where convert(Date, CallStart)

    its an syntax error.

    thanks.

  • to update from another table, you have to establish the relationship betweent he two tables...typically it's a column that has a common value betweent eh two tables:

    Update T2

    Set CallDate = convert(Date, CallStart)

    from T1

    --what relates the two tables together?

    where T1.Id = T2.Id

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • BEGIN

    Update TABLE1

    Set Column1 = (Select convert(date,CallStart) as CallStart

    From TABLE1

    Inner join TABLE2 P ON A.ProcessID = P.ProcessID)

    END

    When I execute the above Query i am faing the following error.

    Msg 512, Level 16, State 1, Line 2

    Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

    The statement has been terminated.

    any idea abt the error.?

    thanks

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply