March 16, 2012 at 4:39 am
Hi All,
Pls explain me the below query
select * from xyz
where year(created_on) <2010
if i give date instead of year it will work?
note: "xyz" is a table and "created_on " is column in my db
Pls advice me
very urgent.
March 16, 2012 at 4:57 am
Where are you going to "give a date"?
Do you mean instead of 2010?
That will not work, as YEAR(myColumn) returns an integer, so it needs another integer to be compared with, otherwise you get incompatible data type issues.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
March 16, 2012 at 5:19 am
Thanks Keon Verbeeck
now i understood.
really thanks
March 16, 2012 at 2:33 pm
The TSQL example below work since you are comparing apples with apples.
select * from xyz where year(created_on) < year('2012-01-01')
-- or
select * from xyz where created_on < '2012-01-01'
John Miner
Crafty DBA
www.craftydba.com
March 22, 2012 at 6:51 pm
faroz2003 (3/16/2012)
Hi All,Pls explain me the below query
select * from xyz
where year(created_on) <2010
if i give date instead of year it will work?
note: "xyz" is a table and "created_on " is column in my db
Pls advice me
very urgent.
What is the datatype of "Create_on"?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply