Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DATETIME field Problem

Status
Not open for further replies.

kernal

Technical User
Feb 27, 2001
415
US
I have a query that has a datetime field and now I need to have a union that will retrieve data from some other tables but for the datetime field in the union, I want the results to have that field empty.

Is this possible?

Thanks for your help.
 
Kernal,

I'm sorry that I don't quite understand all of the issues in your post. In the UNION query:[ul][li]Do you have control over all of the code, including the original portion of the query? (i.e., can the original query change?)[/li][li]If the field will be empty anyway, do you even want the column to appear on output?[/li][li]If a row from the existing query matches (except for the DATETIME) a row coming from another table in the UNION query, do you want the matching row to display?[/li][/ul]

Thanks,

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Does the second table in the UNION also have a datetime field or is the problem that this field is missing and you want to substitute a null value for it ?

If the latter, you can do something like:

select
tabdate
from table1
union
select to_date(null) as tabdate
from table2
 
A view was created for us (the person that created the view is no longer here) that includes a datetime field but some data isn't being retrieved in the query.

I thought I would add a union in the query (there is a table with a datetime field in the union but it isn't the right datetime field) and just leave the union's datetime field empty (the user would then just have to look up the datetime for the ones in the union since there is only a few records). Example:

Original query:

01-01 12/17/2007 11:23:18AM

Union data:

02-01 blank

Thanks
 
Duh, I have it working. I just outer joined the view and used that datetime field and since the data isn't in the view, the datetime field was blank for the union. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top