Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I have a table call rates with the following columns.rateID int Rate decimalDateEffective DateTimeI want to select the correct date based of the effective dateI have triedSELECT * FROM Rates WHERE 01/12/2008 > DateEffectiveBut this doesn't workAny Suggestions?
Nageswar9
Aged Yak Warrior
600 Posts
Posted - 2009-01-27 : 04:54:08
SELECT * FROM Rates WHERE DateEffective < = '01/12/2008'
bklr
Master Smack Fu Yak Hacker
1693 Posts
Posted - 2009-01-27 : 04:55:34
select * from callrates where dateadd(dd,datediff(dd,0,DateEffective ),0) < dateadd(dd,datediff(dd,0,getdate()),0)
Jai Krishna
Constraint Violating Yak Guru
333 Posts
Posted - 2009-01-27 : 05:01:03
select * from callrates where dateeffective < (select max(dateeffective) from callrates)Jai Krishna
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2009-01-27 : 09:23:59
did you meant this?
SELECT * FROM Rates WHERE DateEffective>=DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0)AND DateEffective<DATEADD(dd,DATEDIFF(dd,0,GETDATE()),1)