Monthly Date Range Substitution

Feb 1, 2006

I would like to run a report for each month over two years. I am currently
using a date range like this. Then manually substitute the error_time
bounds for each month and rerun the query. How can I script this so I can
programmatically perform the substitution in a loop. Thanx in advance.


select count(*) from application_errors
where error_message like 'Time%'
and error_time >= '1Apr2004' and error_time < '1May2004'

View 10 Replies


ADVERTISEMENT

Monthly Subtotals From Date Range

Dec 5, 2007

Hi,

My problem is this: a manager has to select 2 dates and from those 2 dates he should see all the times a certain movie has been rented FOR EACH MONTH. For example if he picks 11/1/2007 to 2/1/2008 he sees a total for nov, dec, jan etc. I have a uniqueid for movies called the 'upc' and i have the time and date it was rented 'rental time'

I have a stored procedure with parameters @periodStart and @periodEnd. I am just fine getting the total for the period. but I have no idea how to get the totals for each month. The hint i was given was "grouping data ranges." I have no idea how to tackle this

Maybe a case?

Thanks for your help guys. Let me know if any more info would help.

View 1 Replies View Related

Monthly Subtotals For A Date Range

Dec 5, 2007

Hi,

My problem is this: a manager has to select 2 dates and from those 2 dates he should see all the times a certain movie has been rented FOR EACH MONTH. For example if he picks 11/1/2007 to 2/1/2008 he sees a total for nov, dec, jan etc. I have a uniqueid for movies called the 'upc' and i have the time and date it was rented 'rental time'

I have a stored procedure with parameters @periodStart and @periodEnd. I am just fine getting the total for the period. but I have no idea how to get the totals for each month. The hint i was given was "grouping data ranges." I have no idea how to tackle this

Maybe a case?

Thanks for your help guys. Let me know if any more info would help.

View 1 Replies View Related

Transact SQL :: Split Date Range Into Monthly Wise And Loop Through Each Month To Perform Some Operation

Oct 20, 2015

Let's say if the date is 01/01/2015 till 01/01/2016

I want split these dates monthly format wise and then use them in variable in cursors to loop

For an example Monthly date should be 01/01/2015 and 01/31/2015 and use these two values in 2 variables and make a loop until it never ends whole date range which is 01/01/2016

View 2 Replies View Related

SQL Server 2008 :: Query To Select Date Range From Two Tables With Same Date Range

Apr 6, 2015

I have 2 tables, one is table A which stores Resources Assign to work for a certain period. The structure is as below

Name StartDate EndDate
Tan 2015-04-01 08:30:00.000 2015-04-01 16:30:00.000
Max 2015-04-01 08:30:00.000 2015-04-01 16:30:00.000
Alan 2015-04-01 16:30:00.000 2015-04-02 00:30:00.000

The table B stores the item process time. The structure is as below

Item ProcessStartDate ProcessEndDate
V 2015-04-01 09:30:10.000 2015-04-01 09:34:45.000
Q 2015-04-01 10:39:01.000 2015-04-01 10:41:11.000
W 2015-04-01 11:44:00.000 2015-04-01 11:46:25.000
A 2015-04-01 16:40:10.000 2015-04-01 16:42:45.000
B 2015-04-01 16:43:01.000 2015-04-01 16:45:11.000
C 2015-04-01 16:47:00.000 2015-04-01 16:49:25.000

I need to select the item which process in 2015-04-01 16:40:00 and 2015-04-01 17:30:00. Beside that I need to know how many resource is assigned to process the item in that period of time. I only has the start date is 2015-04-01 16:40:00 and end date is 2015-04-01 17:30:00. How I can select the data from both tables. There is no need for JOIN, just seperate selections.

Another item process time is in 2015-04-01 10:00:00 and 2015-04-04 11:50:59.

The result expected is

Table A

Name StartDate EndDate
Alan 2015-04-01 16:30:00.000 2015-04-02 00:30:00.000

Table B

Item ProcessStartDate ProcessEndDate
A 2015-04-01 16:30:10.000 2015-04-01 16:32:45.000
B 2015-04-01 16:33:01.000 2015-04-01 16:35:11.000
C 2015-04-01 16:37:00.000 2015-04-02 16:39:25.000

Scenario 2 expected result

Table A

Name StartDate EndDate
Tan 2015-04-01 08:30:00.000 2015-04-01 16:30:00.000
Max 2015-04-01 08:30:00.000 2015-04-01 16:30:00.000

Table B

Item ProcessStartDate ProcessEndDate
Q 2015-04-01 10:39:01.000 2015-04-01 10:41:11.000
W 2015-04-01 11:44:00.000 2015-04-01 11:46:25.000

View 8 Replies View Related

Query Info Between Time Range & Date Range

Aug 16, 2006

I am attempting to write a SQL query that retrieves info processed between two times (ie. 2:00 pm to 6:00 pm) during a date range (ie. 8/1/06 to 8/14/06)... I am new to SQL and am perplexed... I have referenced several texts, but have not found a solution. Even being pointed in the right direction would be greatly appreciated!!

View 6 Replies View Related

2nd Question - Date Parameters - To Run A Monthly Report Automatically

Nov 26, 2007



hi there

I am using SQL Server 2005 with Reporting Services (Using the Visual side - not direct code)

I am having problems understanding the dates. eg where to put them,

I want a report that runs on the 1st day of the month for the previous month. I know you can set up something in subscriptions but then how do I get my report header to say from .......to...............

I have been through the AW reports but can't see what I need.

Happy if someone wants to direct me to somewhere that has date examples.

cheers
Dianne

View 5 Replies View Related

Power Pivot :: Calculating Monthly Totals From Date Ranges?

Jul 28, 2015

I am looking to calculate the monthly holidays by staff member using DAX. I am able to calculate it  if all entries (Start Date & End Date)  are confined to a unique month. The issue is where a person's holidays go across several months

I have 2 tables

Table 1 - Holidays
Name                        StartDate                                                 EndDate
Joe Bloggs                 27July 2015                                             7th Aug 2015
Jenny Jones               22nd July 2015                                        23rd July 2015
Jenny Jones               27th  July 2015                                        28th July 2015

Table 2 -Months&Years
Month/Year
June 2015
July 2015
August 2015
September 2015

I am looking for two types of Output  (high level and detailed)

Detailed
Month/Year                        Name                         Total  Days OOO
July 2015                          Joe Bloggs                            5
July 2015                          Jenny Jones                          4
August 2015                      Joe Bloggs                          5

High level Month/Year                       Days OOO
June 2015                                0
July 2015                                 9
August 2015                             5

View 4 Replies View Related

SQL 2012 :: Use Date Trunc Or Date Function To Select Date Range For Month On Month View

Jul 29, 2015

My goal is to select values from the same date range for a month on month view to compare values month over month. I've tried using the date trunc function but I'm not sure what the best way to attack this is. My thoughts are I need to somehow select first day of every month + interval 'x days' (but I don't know the syntax).In other words, I want to see

Select
Jan 1- 23rd
feb 1-23rd
march 1-23rd
april 1-23rd
,value
from
table

View 9 Replies View Related

Reporting Services :: Date Range Filter Based On Date Values Returned In Report?

Aug 27, 2015

I have a QA Deployment Date field that is being returned in a custom report I created. I also found a sample date range parameter:

What I want to accomplish:

I want to select a From and To Date and filter the report to only display the rows that have the QA Deployment Date within the selected range.

For example.. I want to select From Date (8/1/2105) and To Date (8/31/2015) and I only want to return only the results that have a QA Deployment date between that selected range.

View 3 Replies View Related

Date Parameter In SSRS - Allow Drop Down For A Date Range To Be Selected

Aug 11, 2013

Date parameter. I created a report that allows a drop down for a date range to be selected. However, whenever I preview the report, I get an error. I know my error stems from my date fields being in this format "201301" , and the "date/ time" in SSRS being mm/dd/yyyy on the drop down calendar in SSRS.

I know the direction I want to go in, but just a little confused on where would I use the convert or cast function. Would it be in the data parameter itself, or a part of the query before the @start date and @End date?

View 18 Replies View Related

Reporting Services :: Searching By Single Date Or Date Range

Apr 22, 2015

I would like to be able to search by a single date, @StartDate, or by a date range , between @StartDate and @EndDate. I am having a hard time with the logic on this for a report in SSRS.

View 5 Replies View Related

How To Get Latest Temperature Reading For Each Date In A Date Range

Sep 28, 2012

I have to display the last temperature reading from an activity table for all the dates in a selected date range.So if I select the date range from 09/01/2012 to 09/30/2012, the results should look like this:

Date Temperature
09/01/2012 73.5
09/02/2012 75.2
09/03/2012 76.3
09/04/2012 73.3
09/05/2012 77.0
09/06/2012 74.5
and so on.

I am using this to get the dates listed:
WITH CTE_DatesTable
AS
(
SELECT CAST('20120901' as date) AS [Date]
UNION ALL
SELECT DATEADD(dd, 1, [Date])
FROM CTE_DatesTable
WHERE DATEADD(dd, 1, [Date]) <= '20120930'
)
SELECT [Date]
FROM CTE_DatesTable

How could I get the temperature if I did a sub-query here?

View 5 Replies View Related

{RESOLVED} Date Logic - Calculating A Date Range

Jan 23, 2007

I have a report that I need to run on 2 different date ranges.

Both report's data is 2 days behind today's date.
so...
WHERE reportdate between dateadd('d',date(),-2) and dateadd('d',date(),-2)
OR SOMETHING LIKE THAT, NO BIGGIE HERE

The 2nd report is a month to date report. This is the 1 I can't figure out.
WHERE reportdate between (the first day of this month) and dateadd('d',date(),-2)

So that would look like
WHERE reportdate between 1/1/2007 and 1/21/2007

My problem is, if today is the 1st day of the month... how can I get my critiera to NOT do this
WHERE reportdaye between 2/1/2007 and 1/30/2007

Any help would be greatly appriciated!

View 2 Replies View Related

Query Help - Giving A Date Range Given The Start Date, Thanks!

Jul 23, 2005

Hi Group!I am struggling with a problem of giving a date range given the startdate.Here is my example, I would need to get all the accounts opened betweeneach month end and the first 5 days of the next month. For example, inthe table created below, I would need accounts opened between'5/31/2005' and '6/05/2005'. And my query is not working. Can anyonehelp me out? Thanks a lot!create table a(person_id int,account int,open_date smalldatetime)insert into a values(1,100001,'5/31/2005')insert into a values(1,200001,'5/31/2005')insert into a values(2,100002,'6/02/2005')insert into a values(3,100003,'6/02/2005')insert into a values(4,100004,'4/30/2004')insert into a values(4,200002,'4/30/2004')--my query--Select *[color=blue]>From a[/color]Where open_date between '5/31/2005' and ('5/31/2005'+5)

View 2 Replies View Related

Date Picker Controls - Anyway To Limit Date Range

Jul 26, 2007

Have seen other questions here about modifying date pickers supplied by reports created in BIDS. The answer is usually NO. But this does not involve a format change, simply want to limit say to a specific year.
Any ideas?

View 4 Replies View Related

Finding Where My Date Falls In Date Range

Oct 25, 2007

Hi;

We received a Payment from a customer on '10/10/2007 10:30:00'. i am trying to calculate the commission we would receive from that payment. the commission rate can be edited. so i have to find what the commission rate was when that payment was received.


I have a CommisionAudit table that tracks changes in commission rate with the following values.

ID | Commission Change | UpdatedOn
----------------------------------------------
1 | Change from 20->25 | 03/07/2007 09:00:00
----------------------------------------------
2 | Change from 25->35 | 10/09/2007 17:00:00
----------------------------------------------
3 | Change from 35->20 | 01/10/2007 16:00:00
----------------------------------------------
4 | Change from 20->26 | 11/10/2007 10:00:00
----------------------------------------------


with this payment, as the commission rate had been changed on 01/10/2007 it would obviously be 20%(ID 3). But I need to write sql to cover all eventualities i.e. Before the first and after the last. any help would be most welcome.

View 11 Replies View Related

How Can I Add Substitution Variables In My Script?

Oct 11, 2007

Hello,

I want to write a script that will allow the individual running the script (in Management Studio) to be able to insert different values to the WHERE clause. Basically I want to prompt the user for his/her input. How can I accomplish this?

Thanks for the help!
Layes

View 4 Replies View Related

Substitution Variables To Temporarily Store Value

Dec 13, 2013

I am looking for "substitution variables to temporarily store value" with sqlcmd in sql server . I know the query in oracle, but looking for equivalent query in sql server?

In oracle query is like this:

select *
from tablename
where deptnumber = &department_number;
Enter Value for department_number

I am looking this query in sql serevr2008.

View 10 Replies View Related

Range In Date

Aug 30, 2007

 
I have a order table which has a orderdate and despatchdate
i want to write a query in such a way that i want to get all the details from the table for a range specified date as the oderdate and despatchdate are user
interactable. I search the google to solve this problem but could not find a answer
 

View 10 Replies View Related

Date Range

Jan 14, 2005

What is the best way to do a where clause that includes a date range. Ex. WHERE date1 BETWEEN @Begin Date AND @EndDate. I want to include all of the @EndDate.

View 6 Replies View Related

Sum By Date Range

Aug 9, 2007

I am working on a report for staff productivity, and have to get a summary figure for how much productivity was expected for a date range. The problem is that the amount expected from an employee can change if they move from full time to part time etc.

So I have a view that has the begin date, end date, expected daily production # by employee, and have to figure out how to get the multiplication to work correctly.

Example:

Employee 1 had a daily production # of 10 from 1/1/07-3/31/07 and daily production of 5 from 4/1/07 - now

If I run the production report for 1/1/07 - 6/30/07 what I want is one summary figure of for the entire range which would be 10*Datediff(d,1/1/07,3/31/07)+5*Datediff(4/1/07,6/30/07) or 890+450=1340.

Of course the actual date range for the report will be a variable, and the dates for the begin and end of a production date range will be all over the place.

Any quick and easy way to do this?

View 4 Replies View Related

Date Range

Apr 7, 2008

Hey guys..
pls help

what query should I do? Obtaining certain date only using SQL server2000?

Thnx...

View 4 Replies View Related

Date Range

Jun 18, 2006

Hi All,

I am very new to SQL and have a question, hopefully someone can answer.

I have a table of data, one of the fields is a date.

What i want to do is be able to have a query that can check if the date falls within a certain range - ie fiscal year and output in another column the fiscal year "code".

Ie: dates between 01/06/05 and 31/05/06 is fiscal year 0506
dates between 01/06/06 and 31/05/07 is fiscal year 0607

Could this query be dynamic so if a new fiscal year begins it would know to make the output the next fiscal year code???

Any help is much appreciated.

Cheers

Rudi

View 8 Replies View Related

Date Range

Oct 2, 2006

Hi, 'am fairly very new to SQL SERVER 2000.

I have this particular problem....I need to develop a stored proc
where in a parameter checks the dates between JAN 1st and DEC 31st of a particular year. The parameter is declared for year..

I'll mention a small example below...


USE PUBS
declare @year as varchar
set @year = 1993

select * from employee
where hire_date >= '@year-01-01'
and hire_date<='@year-12-31'

This is just an example to show wat i want...
the year is prompted to the user...he/she can select any year

I get the following error message....

Server: Msg 241, Level 16, State 1, Line 1
Syntax error converting datetime from character string.

Can anyone help me on this......

Thanks in advance

View 9 Replies View Related

Date Range

Mar 12, 2008

How to display start date and finish date together in the same column with a '-' in between?

2/24/2008 - 3/1/2008

View 3 Replies View Related

Get Date Range

Apr 5, 2006

I have a function that takes in a week number and returns data based on that week number, for one client we have a table that tells what the weeks are since they are not on a normal calendar, but their fiscal calendar. We now have another client that want the same function, but for it to return the data based on the normal calendar week. So, how can I determine the date range of a week, based on the week number?

View 3 Replies View Related

Date Range With MDX

Nov 16, 2007



I want to return data from a date range using MDX. The user will pick a month and a number for the number of previous months to display. So far, using SSRS to write my MDX code I have:


SELECT NON EMPTY { [Measures].[Steel Margin], [Measures].[Coil Weight], [Measures].[Amount], [Measures].[Gross Margin], [Measures].[Gross Profit] } ON COLUMNS, NON EMPTY { ([Date Shipped].[Month].[Month].ALLMEMBERS * [Out Rep].[Rep].[Rep].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM ( SELECT ( STRTOSET(@DateShippedFiscalYear, CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOSET(@DateShippedMonth, CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOSET(@DateShippedYear, CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOSET(@OutRepRep, CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOSET(@DimSalesTypeDescription, CONSTRAINED) ) ON COLUMNS FROM [Heidtman DW]))))) WHERE ( IIF( STRTOSET(@DimSalesTypeDescription, CONSTRAINED).Count = 1, STRTOSET(@DimSalesTypeDescription, CONSTRAINED), [Dim Sales Type].[Description].currentmember ), IIF( STRTOSET(@DateShippedYear, CONSTRAINED).Count = 1, STRTOSET(@DateShippedYear, CONSTRAINED), [Date Shipped].[Year].currentmember ), IIF( STRTOSET(@DateShippedFiscalYear, CONSTRAINED).Count = 1, STRTOSET(@DateShippedFiscalYear, CONSTRAINED), [Date Shipped].[Fiscal Year].currentmember ) ) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS



I have two other parameters: StartMonth and RollBackNumber. RollBackNumber will be the number of months and StartMonth will be my computed start parameter. I can write some code if necessary to compute the StartMonth (something like [Date Shipped].[Month].&[2007]&[3]&) if I have to.

View 11 Replies View Related

Date Out Of Range?!

Jun 26, 2006

Greetings!

I have a data source that gets generated based on a variable with the following SQL :

"select * from result where deletion_ind = 1 and when_deleted >= '" + (dt_str, 50, 1252) @[User::Last_Run_Date] + "'"

But when I run my package I get an error message saying:

The conversion of CHAR to DATETIME resulted in a DATETIME value out of range

The Last_Run_Date variable is set to '2006-06-25 14:35:05.450'

When I run the code in a QA session it works, but in the package it complains! What am I doing wrong?



Thanks for your help in advance.

View 35 Replies View Related

Dynamic Evaluation Of Expression Operator (was Substitution)

Jan 27, 2005

Hi I am trying to do something like the following:

DECLARE @Operator varchar(1)
DECLARE @Rate float
DECLARE @Quantity float
DECLARE @Converted float

SET @Quantity = 6
SET @Operator = '/'
SET @Rate = 2
SET @Converted = 0

@Converted = (@Quantity substituteTheValueOfThis(@Operator) @Rate)

PRINT @Converted

so that the output would be 3

The reason I need to do it like this is that @Operator will change at runtime...

Any suggestions appreciated, I have looked at EXEC sp_execsql but somehow can't get the syntax right.

View 5 Replies View Related

SSIS And XML Schemas - Substitution Groups Not Supported

Feb 14, 2008

I'm looking at building an SSIS workflow to integrate new XML product data from our supplier (they're switching to XML instead of the Current MS Access database they use). They're using a schema based on the OAGIS structure. When I try to load a Data Flow Task with the XML file, to attempt to parse it, and I specify the XSD schema they have provided, SSIS errors out by telling me:

TITLE: Microsoft Visual Studio
------------------------------

Error at Data Flow Task [Data Import [1]]: The component "Data Import" (1) was unable to process the XML data. Substitution Groups not supported. See element "Dimensions" with "substitutionGroup=http://www.openapplications.org/oagis/9: Dimensions".

------------------------------
ADDITIONAL INFORMATION:

Pipeline component has returned HRESULT error code 0xC02092B0 from a method call. (Microsoft.SqlServer.DTSPipelineWrap)

------------------------------
BUTTONS:

OK
------------------------------




Is there any way at all to get around this, or am I screwed? As I said, this data is provided to us by our supplier - we have no control over it, but I am looking to pull the data from XML and put it into a regular SQL table which I am in the process of defining - we have a large traffic e-commerce site and obviously cannot use XML as the "back-end".

View 3 Replies View Related

Sql Server Date Range

Apr 12, 2008

 I have a table namely "Information"  , it has one field namely " Lastupdate" when i insert or update data , lastupdate column takes takes current datetime value.  and this data i am displaying in another  page . Here i want to display the information upto 21 days from last updated dates. means if i save data today (12/04/2008) then the "lastupdate"  value will be (12/04/2008) and when i display this data should display upto 21 days means upto  (23/04/2008) when date 24/04/2008 will come, this data should not display.  and i want this from sql server query , if anybody have idea please write query for that , its very urgent ..............

View 2 Replies View Related

Compare Date Range

Aug 2, 2000

I want to write a query to retrieve all the items that are
order between 2 dates range, 07/30/2000 to 08/02/2000, any suggestions are
greatly appreciated,

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved