Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««123

Last Day of Month subscription for Shared SSRS schedule Expand / Collapse
Author
Message
Posted Sunday, August 22, 2010 8:18 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 8:58 PM
Points: 36,794, Visits: 31,253
SqlServerLover (8/22/2010)
I did not mean to run manually.
Set up shared schedule to run at 12 am on the 1st of the month.


That's what I'm talking about. What happens if there's a catastrophic event or other incident that prevents the job from running at 12AM on the 1st of the month?

You have to prepare for the worst because the worst will happen.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #973157
Posted Tuesday, August 14, 2012 10:47 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, October 15, 2013 3:21 PM
Points: 23, Visits: 73
I created it as a stored procedure in SSMS so I could use it for multiple reports and then just add it as a dataset in SSRS.

First Day of Previous Month:
SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) - 1, 0)

Last day of Previous Month (Time set to 11:59:59pm)
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0))

I don't remember what i did after that to get it working, but I think it's pretty obvious if you use the wizard. If you have any problems with this let me know and I'll look into it further.

David92595
Post #1344879
Posted Tuesday, August 14, 2012 11:07 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 7:45 PM
Points: 23,081, Visits: 31,620
David92595 (8/14/2012)
I created it as a stored procedure in SSMS so I could use it for multiple reports and then just add it as a dataset in SSRS.

First Day of Previous Month:
SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()) - 1, 0)

Last day of Previous Month (Time set to 11:59:59pm)
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0))

I don't remember what i did after that to get it working, but I think it's pretty obvious if you use the wizard. If you have any problems with this let me know and I'll look into it further.

David92595


What is the data type of the date/time values you compare the above to? A better way is to use an open-ended value at the upper end of the range test. Instead of

somecolumn <= DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0))

you should use

somecolumn < DATEADD(mm, DATEDIFF(m,0,GETDATE()),0)




Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1344896
Posted Tuesday, August 14, 2012 11:18 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, October 15, 2013 3:21 PM
Points: 23, Visits: 73
Either one works, I prefer to define/ know the exact time the query will be using. Which include the time being 11:59:59...
Post #1344903
Posted Tuesday, August 14, 2012 11:28 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 7:45 PM
Points: 23,081, Visits: 31,620
David92595 (8/14/2012)
Either one works, I prefer to define/ know the exact time the query will be using. Which include the time being 11:59:59...


The way I showed above does the same thing, you would be pulling all records (for example) greater than or equal to '2012-07-01 00:00:00.000' and less than '2012-08-01 00:00:00.000', there by getting all records for July 2012. Also, it won't be affected by a change in datatype. Using 11:59:59 can miss records greater 11:59:59.000 and less than 00:00:00 of the following day if your column in the comparision is defined as a datetime data type.




Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1344908
Posted Friday, April 26, 2013 7:31 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Yesterday @ 11:34 AM
Points: 453, Visits: 570
For various reasons lotsof things get set to zero at 00:01 on the first day of the month, so running thereports then isnt a possibility. However running all the queries i need into a set of temp tables at 23:00 on the last day and the reports running from them just after midnight is a work round. Not an elegant one but it is simple. May not be suitable for everyone......
Post #1446986
« Prev Topic | Next Topic »

Add to briefcase «««123

Permissions Expand / Collapse