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
 General SQL Server Forums
 New to SQL Server Programming
 Query Help

Author  Topic 

jhon11
Starting Member

42 Posts

Posted - 2007-11-12 : 15:41:06
Can anybody tell me that how to write short query insted of writing all dates...

select patient_id , prescriber_id From dbo.Child_Patient_Drug_List_History
where prescriber_id !='000000000'
and Report_Period in('07/2006','08/2006','09/2006','10/2006','11/2006','12/2006','01/2007','02/2007','03/2007'))


I want to avoid of writing all dates...one by one..because it will be hard to modify ...

Looking for a reply

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2007-11-12 : 15:43:50
We have covered this in one of your other threads...in fact, you may want to keep all of your questions to one thread, so other people (not just me) don't apparently waste their time trying to help.

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=92500
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=92509

and (Right(Report_Period,4) *100)+ Left(report_period,2) >= 200607 and
(Right(Report_Period,4) *100)+ Left(report_period,2) <=200703

quote:

Looking for a reply



Of course you are, why post otherwise! Of course, this wreaks of a homework assignment and you aren't going to get anywhere or learn anything by posting every question requiring a query as a separate thread titled "query help" or "help query".

I don't mind helping, but help your self a little bit if you expect any more.



Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

jhon11
Starting Member

42 Posts

Posted - 2007-11-12 : 15:51:39
Thk You very much ...really appreciate..

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-13 : 02:43:14
quote:
Originally posted by jhon11

Can anybody tell me that how to write short query insted of writing all dates...

select patient_id , prescriber_id From dbo.Child_Patient_Drug_List_History
where prescriber_id !='000000000'
and Report_Period in('07/2006','08/2006','09/2006','10/2006','11/2006','12/2006','01/2007','02/2007','03/2007'))


I want to avoid of writing all dates...one by one..because it will be hard to modify ...

Looking for a reply


Always use proper DATETIME datatype to store dates. It is your front end application where formation matters

Madhivanan

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

arorarahul.0688
Posting Yak Master

125 Posts

Posted - 2007-11-13 : 05:44:01
quote:
Originally posted by dataguru1971

We have covered this in one of your other threads...in fact, you may want to keep all of your questions to one thread, so other people (not just me) don't apparently waste their time trying to help.

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=92500
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=92509

and (Right(Report_Period,4) *100)+ Left(report_period,2) >= 200607 and
(Right(Report_Period,4) *100)+ Left(report_period,2) <=200703

quote:

Looking for a reply



Of course you are, why post otherwise! Of course, this wreaks of a homework assignment and you aren't going to get anywhere or learn anything by posting every question requiring a query as a separate thread titled "query help" or "help query".

I don't mind helping, but help your self a little bit if you expect any more.



Poor planning on your part does not constitute an emergency on my part.





very same logic with other string functions
select convert (varchar(12),date,101) from testing
where convert(varchar(4),year(date))*100+convert(varchar(2),month(date)) >=200607
and convert(varchar(4),year(date))*100+convert(varchar(2),month(date))<=200703

*100 this is very crucial because otherwise it will not produce write answer thanks to make a gud logic in my knowledge

Rahul Arora
MCA 07 Batch
NCCE Israna, Panipat
HRY, INDIA

######################
IMPOSSIBLE = I+M+POSSIBLE
Go to Top of Page

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2007-11-13 : 13:33:58
quote:

very same logic with other string functions
select convert (varchar(12),date,101) from testing
where convert(varchar(4),year(date))*100+convert(varchar(2),month(date)) >=200607
and convert(varchar(4),year(date))*100+convert(varchar(2),month(date))<=200703

*100 this is very crucial because otherwise it will not produce write answer thanks to make a gud logic in my knowledge

Rahul Arora
MCA 07 Batch
NCCE Israna, Panipat
HRY, INDIA

######################
IMPOSSIBLE = I+M+POSSIBLE




it isn't the same logic at all, and I am pretty convert which uses more resources than mine would. The main issue as Madhivan pointed out is how the dates are stored anyway..

If you are going to rewrite other people's answers, at least make it an improvement to the original. Posting bad answers to solved problems only creates more confusion.



Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page
   

- Advertisement -