When using UNION I receive "Cannot convert '' to a timestamp" when I try to run something like this:

select [field1], [field2] from [table]

union

select [field1], '' from [second table];

Field1 is the same in both tables. In the first select statement field2 data type is timestamp but I don't want field2 pulled from the second select statement. Is there a way to cast or format field2 in the second statement to run in this instance?

Appreciate any assistance.

asked 01 Jun '11, 15:32

zippidydo's gravatar image

zippidydo
377151521
accept rate: 0%


Try NULL instead of ''.

permanent link

answered 01 Jun '11, 15:36

John%20Smirnios's gravatar image

John Smirnios
9.0k377114
accept rate: 39%

Great. That did the trick. Much appreciated.

(01 Jun '11, 16:17) zippidydo
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×10

question asked: 01 Jun '11, 15:32

question was seen: 680 times

last updated: 01 Jun '11, 16:17