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.
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_Historywhere 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=92500http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=92509and (Right(Report_Period,4) *100)+ Left(report_period,2) >= 200607 and (Right(Report_Period,4) *100)+ Left(report_period,2) <=200703quote: 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. |
|
|
jhon11
Starting Member
42 Posts |
Posted - 2007-11-12 : 15:51:39
|
Thk You very much ...really appreciate.. |
|
|
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_Historywhere 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 mattersMadhivananFailing to plan is Planning to fail |
|
|
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=92500http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=92509and (Right(Report_Period,4) *100)+ Left(report_period,2) >= 200607 and (Right(Report_Period,4) *100)+ Left(report_period,2) <=200703quote: 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 functionsselect convert (varchar(12),date,101) from testing where convert(varchar(4),year(date))*100+convert(varchar(2),month(date)) >=200607and 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 knowledgeRahul Arora MCA 07 BatchNCCE Israna, PanipatHRY, INDIA######################IMPOSSIBLE = I+M+POSSIBLE |
|
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2007-11-13 : 13:33:58
|
quote: very same logic with other string functionsselect convert (varchar(12),date,101) from testing where convert(varchar(4),year(date))*100+convert(varchar(2),month(date)) >=200607and 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 knowledgeRahul Arora MCA 07 BatchNCCE Israna, PanipatHRY, 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. |
|
|
|
|
|
|
|