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 |
|
ayu
Starting Member
43 Posts |
Posted - 2008-06-23 : 19:07:34
|
| Hi ALL,Well, i have one view:create view vwdateasselect custno, custname, city, datefrom salestabwhere date = ????well, this question mark...i have to fill..like i want if month is june then i want for whole may month results of custno, custname and city..if month is july then i want results for whole june month..means for previous month results i want whatever the date is for that particular month..Example:if date='06/15/08'then results will becustno custname city date---------------------------------1 AAAA NJ 05/01/08 2 SDS CT 05/04/08........................ 05/18/08.......................... 05/30/08if date='06/30/08' OR '06/1/08' then also results will be same..so i want for previous month results..so can anyone help me to get the correct condition in where clause?Thanks ALL.. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-06-23 : 19:54:09
|
[code]CREATE VIEW vwdateASSELECT custno, custname, city, [date]FROM salestabWHERE [date] >= DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) - 1, 0)AND [date] < DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0)[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
ayu
Starting Member
43 Posts |
Posted - 2008-06-23 : 20:21:45
|
| thanks khtan..got the perfect results..thanks.. |
 |
|
|
|
|
|
|
|