Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

copy (convertable) varchars to datetime

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-
  • 2
1 Solution
update order set inhand_date = case isdate(due_date) when 0 then null else cast(due_date as datetime)
ottenmAuthor Commented:
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?
ottenmAuthor Commented:
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now