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.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 not in clause with date function

Author  Topic 

mateenmohd
Constraint Violating Yak Guru

297 Posts

Posted - 2005-08-01 : 07:16:09
Hi,

User only allow to insert Thursday date in MH1 table.
if user wrong insert other date in the table
how can find the other dates data are insert in the table ?

ie

select * from mh1
where dated not in ('12/23/2004','12/30/2004','1/6/2005','1/12/2005',.................)

how can use date function in above query which retrieve data other then Thursay date ?

regards.

Mateen






Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2005-08-01 : 07:25:02
If sunday is 1, then thursday is 5:

so

Select * From mh1 Where datepart(dw,dated)<>5

Corey

Co-worker on The Wizard of Oz "...those three midgets that came out and danced, the freaked me out when I was little. But they are ok now."
Go to Top of Page

mateenmohd
Constraint Violating Yak Guru

297 Posts

Posted - 2005-08-01 : 07:42:51
Thanks for response.

for current year it is ok.
we have also 2004 thursday date in the table.
it should not retrieve year 2004 thursdate date how ?

regards.

Mateen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-01 : 07:48:16
Select * From mh1 Where datepart(dw,dated)<>5 and year(dated)<>2004


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

mateenmohd
Constraint Violating Yak Guru

297 Posts

Posted - 2005-08-01 : 08:31:05
Thanks

Mateen
Go to Top of Page
   

- Advertisement -