Welcome :Guest
Congratulations!!!

Top 5 Contributors of the Month
ffttt

### Using datediff to calculate elapsed time

Hi..my app requires an elapsed time calculation that I have done like thisCONVERT(Varchar, (DATEPART(dd, GETDATE() - DateAdded)-1) * 24 + DATEPART(hh,GETDATE() - DateAdded)) + 'h:' + CONVERT(Varchar, DATEPART(mi, GETDATE() - DateAdded)) + 'm' AS ElapsedTimeThis works.. I can then colour my grid view cells  accordingly using the substring function.. the problem is that I have been told that using GETDATE three times is not a good use of resources, is it possible to use the Datediff function to get the same result?thanksDan

### calculate between end time and start time workdays only

hi, i'm using the formula =DATEDIF([Start Time], [End Time],"d") to calculate the difference between 2 dates. now i need a formula that only calculate the workdays.

### Dimension Range over time

Is there a method for categorizing measures into ranged dimension attributes over time.  Consider the SQL:       SELECT date, sales = SUM(sales), segment = CASE WHEN SUM(sales) BETWEEN 0 AND 99 THEN 0 WHEN SUM(sales) BETWEEN 100 AND 199 THEN 100 ELSE 300 END      FROM tabl1      WHERE date BETWEEN '01/01/1900' AND '12/31/1900'   Date Sales Segment 1/1/1900 100 100 1/2/1900 150 100 1/3/1900 49 0 1/4/1900 175 100 1/5/1900 99 2 … … … Is it possible to apply this logic across a time range?  For example, this is on a daily basis, is it possible to do this on a monthly, yearly basis or for a range like '01/02/1900' - '05/25/1900' at monthly rollup? Month Sales Segment January 999 300 February 1 0 March 500 300 April 199 100 May 99 0 … … … I've done this using keys on the fact table; they aren't dynamic, but aggregate the measures into defined buckets January 1900, February 1900, etc.  My keys on the fact table are at the monthly level.

### T-SQL query, average of daily time periods over a date range

Hi,

I'm building a report in Crystal Reports using a SQL command against a T-SQL 2005 telephony database.

I need to be able to run the query across a given datetime range, 6 months for example and bring back a 5 day display (Mon-Fri) with a group for every 15 minute interval in each day.

The group figures need to contain an average of the amount of calls presented for each 15 minute interval on any day across the whole datetime range, so for example the Monday 10:00 - 10:15 figure would be an average of all calls presented in every 10:00-10:15 range on each of the Mondays that fall within the datetime range.

I've got a query built now that gives total presented figures grouped by these intervals across one week but I can't figure out how to do this average function across a range.

Does anyone have any idea how I'd go about accomplishing this? I'm pretty new to SQL but keen to learn so any pointers on functions to research etc would be very much appreciated.

Query for detail view across one week included below for table/fields etc...

SELECT

count(DISTINCT Calls.SessionID) as Presented, min(Calls.startDateTime) as DateTime

FROM
Calls
INNER JOIN QueueDetail
ON Calls.sessionID =  Queues.sessionID
AND Calls.sessionSeqNum =  QueueDet

### Get Average from interval(Time) by hour

You Got to love management,

I've been averaging for the last 12 records with this code:

```SELECT AVG(LMP) AS Average FROM (SELECT TOP (12) LMP FROM dbo.LMP_5Min order by id desc)
derived
```

I need to get the average for just the current hours data that comes in every 5 minutes.  So there will be 12 records by the end of the hour.  However I need to average each increment as it comes in.  So after 1, 2, 3...... increments come in each would have to be averaged.

My tables goes as follows:

5MIN_LMP

ID                  int, not null

Day         &n

### How to Get Total Minutes From Hours in SQL Server 2005?

Hi All.........!

I have 10:45 Hours and Now I want to get Total Minutes Like 645 Minutes.

How Can I Get in SQL Server 2005?

### Range dimension - possible with Relative Time Periods?

Hi All,

I have a Date_Range dimension with members 7 days, 30 days and 90 days only.
Although all reporting needs could be well address using existing date dimension and
MDX filter or range operator I need a physical Date_Range dimension.

It seems possible to address my requirement (implementing Date_Range dimension) by Handling Relative Time Periods .
The blog post (by Chris) is rather old and I did not find updates on it or recent similar articles.

Thanks,

Prakash Gautam

### SSRS 2008 Time min change to hour

Hi there

I've got a problem in my report.

I have 2 colums "Expense" "Entity"

Expense has an issue 300 and entity min.

what i'd like is, that it change to 5 hours.

but it should issue min if expense is below an hour.

Any ideas?

### How to Define a "Total" to Calculate Percentage for SKU in PivotTable?

Let's take a look at a sample PivotTable below:

SKU     \$     NewMeasure

111     5      30 (5+ 10 + 15)

222     10     30 (5+ 10 + 15)

333     15     30 (5+ 10 + 15)

SKU     \$     NewMeasure

111     5      20 (5+ 15)

333     15     20 (5+ 15)

How do I go about defining the "NewMeasure" calculated member in my AS2008 Enterprise cube?  The NewMeasure should essentially be the total \$ amount for all SKUs in the current PivotTable.

What I'm really after, in this particular example, would be the percentage of a given SKU's \$ amount relative to the total \$ amount for all SKUs in the current pivot.  I figured if I can get the "NewMeasure" logic figured out, the above would be easy.

In summary, my goal is:

SKU     \$     NewMeasure         NewMeasure2

111     5      30 (5+ 10 + 15)    5/30

222

### Calculate total sum

Hello

I have following table named example sales:

Id         Name         Price

1             a1               4

2             a2               7

3             a3               1

4             a4               3

I whant to calculete total sum of price this will be 15 and after that create new column wich will have following formula Total Sum of price - price,

example for first columnt 15-4=11 and the result must be:

Id         Name         Price       new_column

1

### How to display/calculate total of a custom column in dataview webpart's grouping header

Hi,

I've created a dataview from a MOSS2007 form library. In the dataview, I've enabled grouping by a specific column and also was able to show the total (sum) of couple of columns like this, in the group heading:

<xsl:value-of select=”sum(\$nodeset/@Total_x0020_Cost)” />

So far, it's working fine. I've added couple more columns to this dataview. There's a piece of javascript code that is executed for each row. These 2 columns gets their value from this javascript. Now, is there anyway, I can get the total/sum of these columns in the group heading.

Thanks,

Pman
http://www.pmansLab.com/

### Calculate Web Application Idle Time

Hi all,

I have a requirement to calculate the Web application idle time.

Say the user doesnt use the web application for 15 minutes, then a message needs to be displayed to the user.

How can this be done.

### How to calculate max,minaverage and total in ssrs matrix report

Hi,

in SSRS 2005 matrix report, i would like to do following thins

1- Calculating Max,Min,agerge and Sum for each Row.

2- i have to put this calculated result   before matrix column group.

i have 4 row groups in my report. i am expecting report like this:

Country   State   City    Dealer      Min Max Agerage Total 1-oct-2010  2-oct-2010    ......

here first four columns i have created as row and Date as matrix column this is dynamic based on rage selected from parameters.

Regards

SK

### Converting Date Time to Minutes

Hi,

I have a database column in datetime datatype . From the datetime column I applied the formula :

`substring(convert(varchar(10),[Received time],108),1,5)`

which gives me values like 06:00 (HH:MM)

I need to get the minutes from the HH:MM like 06:00 - 360 minutes ( numeric) as I will later be required to do an average of the minutes.

I need to convert HH:MM to represent only minutes in Numeric. Please let me know on this.

Thank You

EVA05

### How to calculate the total of wpf datagrid text column

Hi,

I have WPF DataGrid that is bound to and entity.

The DataGrid has a "Difference" column that is computed from the difference between two other columns in the same DataGrid.

Now I have a TextBox outside the data grid that should contain Sum of all cells in the "Difference" column.

How do I do that?

```<DataGrid AutoGenerateColumns="False" HorizontalAlignment="Stretch" Margin="5,35,150,40" Name="BoxCountDataGrid" VerticalAlignment="Stretch" ItemsSource="{Binding UpdateSourceTrigger=PropertyChanged, Path=DemersalBoxCounts}" >

<DataGrid.Columns>

<DataTemplate>
<TextBlock Text="Recorded Box Unit/Weight(kg)" Width="70" TextWrapping="Wrap"/>
</DataTemplate>
</DataGridTextColumn>

<DataGridTextColumn Binding="{Binding DEBC_BCT}" Width="*">
<DataTemplate>
<TextBlock Text="Box Count" Width="70" TextWrapping="Wr```

### "Date&Time" column in list - set actual time and sharepoint's proposes wrong hour (eg. 17:00 instea

I created new column in list - Date and time (Date and time format: Date&Time, Default value: Today's Date)

The problem is, when I create new item in list, the default time is always set as next full hour, eg. now it's 13:15 or 13:31 ora 13:57 and in aspx form it's all the time 14:00. Obviously, I can change that date with 5 minut precision (13:05, 13:10, 13:15 etc.), but it's kind of annoying.

### SUM for 60 minutes after given time

I have a Dim Campaign (Created showing every time we send an email campaign out to people). Each of theses Campaigns has a time associated with it (Time Dim). Hour -> Minute -> Second

What I want to calculate is the SUM of the transactions ([Measures].[Transaction]) for the 60 minutes following the sending out of the campaign.

Does this makes sense?