copy (convertable) varchars to datetime

Posted on 2007-07-23
Last Modified: 2012-06-21
I'd like to copy the varchar field 'due_date' to the datetime field 'inhand_date' throughout the table 'order', leaving all the inhand_date's NULL where the conversion fails.  Probably just have the wrong mix of isdate() and convert().  

Help appreciated-
Question by:ottenm
    LVL 15

    Accepted Solution

    update order set inhand_date = case isdate(due_date) when 0 then null else cast(due_date as datetime)

    Author Comment

    thanks derekkromm, that would have done it except I am getting "max row size" errors when adding inhand_date to order.  What if inhand_date ends up in order_1, how to get due_date from order?

    Author Comment

    I could not get the code above to work with cast, but I did get it with convert (also by adding 'end').  This copies the (convertable) varchars in

    UPDATE o1 set inhand_date = case isdate(o.due_date)
          WHEN 0 then null else convert(datetime, due_date) end
    FROM order_1 o1
    JOIN order o ON o1.document_id = o.vt_document_id

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now