|
SELECTING empty months: msg#00357windows.devel.dotnet.winforms
Hi, In my application users have to enter in data once a month. I need to try and create a query where I can see what months are filled in but then I need to return the missed months. I've got up to where I have the dates that are missed, but how do I return them as a result set? The variable @EMPTY_MONTHS contains the missed months but I just need to know how to put them in a result set and return them? DECLARE @INSTALLATION_DATE DateTime DECLARE @NO_MONTHS int DECLARE @EMPTY_MONTHS varchar(50) DECLARE @COUNTER int DECLARE @TABLE_NAME varchar(50) SET @TABLE_NAME = '__After_Hours_Monthly' SET @INSTALLATION_DATE = (Select Installation_Date From __Installation_Date) SET @NO_MONTHS = DATEDIFF(m,@INSTALLATION_DATE,GETDATE()) WHILE @NO_MONTHS > 0 BEGIN SET @INSTALLATION_DATE = DATEADD(mm,1,@INSTALLATION_DATE) SET @NO_MONTHS = @NO_MONTHS - 1 SELECT * FROM __After_Hours_Monthly WHERE DATEPART(m,EntryDate) = @INSTALLATION_DATE IF @@ROWCOUNT = 0 BEGIN SET @EMPTY_MONTHS = @EMPTY_MONTHS + ',' + CONVERT(VARCHAR,@INSTALLATION_DATE) END END |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: SQL: 00357, Andrew Dunn |
|---|---|
| Next by Date: | Re: Outlook 2003 integration: 00357, Booth, Bill |
| Previous by Thread: | SQLi: 00357, Andrew Dunn |
| Next by Thread: | DataGrid Binding Display Junk Characters: 00357, Mihir Pathak |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |