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!

SQL Expression Help - select by day,month,year ...

Status
Not open for further replies.

TomSalvato

Technical User
Mar 24, 2010
64
US
Hi All - I'm trying to get some SQL expressions to work (using Crystal2008 and Oracle DB) ... I basically need to compare a datetime var in the two tables ...
I need the Oracle equivalent to this crystal psuedo-statement ...

day(TABLE1.datevar) = day(TABLE2.datevar) and
month(TABLE1.datevar) = month(TABLE2.datevar) and
year(TABLE1.datevar = year(TABLE2.datever)

both those fields have times that I'm trying to ignore, so the match on day, month and year will work for me ... just don't know how to phrase it in Oracle ...

(
select distinct count("TABLE1"."OBJECTID")
from "DB"."TABLE1"
where
// day(TABLE1.datevar) = day(TABLE2.datevar) and
// month(TABLE1.datevar) = month(TABLE2.datevar) and
// year(TABLE1.datevar = year(TABLE2.datever)
)

-TS
 
In oracle

trunc(TABLE1.datevar) returns date only removing the time.

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top