.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

Equivalent functions for justify_hours, sum(interval), avg(interval) like in postgress

Posted By:      Posted Date: October 26, 2010    Points: 0   Category :Sql Server


I am migrating my postgres database to MS SQL Server 2005. I had some sql queries that used for reporting module in my application.

These queries contains fields of data type "interval" in postgres. Also it has sum and avg aggregate functions on these fields.

I searched for equivalent functionality in MS SQL Server 2005. But it seems that aggregate functions like sum and avg in MS SQL Server 2005 works either with int, float,decimal,money and not with datetime rather time.

I would like to know how can I do this. Also is there any equivalent function to justify_hours in postgres

Thanks in advance. Any help appreciated.

View Complete Post

More Related Resource Links

Trying to set Calendar Time Interval Using Calculated Column, but getting Error



So i was trying to use a calculated column that added 7 days to the start date of a calendar item. The calculated column worked fine because i checked with several tests. Then i tried using the Column as the End Time in the Time Interval Setting in the Calendar View. This broke Sharepoint. Not the normal graceful error im using to seeing from Sharepoint but the Server Error Page when a dump happens in a ASP page. I havent enabled the full error page because i assume its not like i can fix it, i dont have the source code.


Does anyone else experience this? If so is it a known problem and being worked on?




Date Time interval Problem

Hi I have a problem in which i have to check the time interval to the another which is already exist in Database table.For Exp.10:00 am  To 11:00 am i add an Event now if user insert the again this time interval  it's throw the error message.if user want's to edit this event For exp.10:15 am to 11:00 amhow do this.Thanks

MP3 Uploading with time interval selection

I am writing a music related web site. What I am trying to do is have the user upload a song (MP3, MP4, Wav). I then want to be able to slice the song to a max lengh of 30 seconds. The user would be able to select a starting point and I would cut the song down to 30 seconds from that point. Any ideas on how to get started on this? Thanks

Is there a way to specify that I do not want fractions for my interval on a chart axis ?

Using reporting services 2008 I have a bar chart which shows number of employees by department. When the number of employee is small, I get fractions on the Y axis like 0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2 I know that I can manually set the interval to 1 which solves the problem but I also have the same problem with bigger numbers (I also have the scale breaks enabled) For example when I have 40, 44 and 66 in my dataset the Y axis is as follow: 39.6, 39.8, 40.0, 40.2, 43.6 (scale break), 65.6 (scale break), 66.1 This is not really what I expected... Is there any way to get a better behavior ? Thanks Paul

Display Page Elements After Interval

Hello,I'd like to display certain elements of my page after an interval.  I've tried using the 'UpdatePanel and Script Manager', but it seems to Refresh my page after each interval.How do I prevent that from happening?There are 3 parts that I want to display, each after 1.5seconds (Div with large letters "Success" (Will happen after a Page.PostBack), Div that Displays Comparisons, Div that Displays the Sample)Is there a way to write the code inline, so when the page loads the timer intervals dont reload the page?

return rows with constant interval

what function should we use to return all alternate/ or rows that come after some constant number.   Please advice

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)

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:


ID                  int, not null

Day         &n

C# string has CRLF inserted @ 1024 interval


I use the following to test in VS2005, VS2010, Winform and WebForm and I got the strange result of a string with a CrLf inserted at 1024 intervals. Anybody has any idea?

When I use this to construct <html>, if the CRLF falls in a <td > then it;'ll break. I also tried to use string builder, same effect.

            s += "0123456789";

         string s = "";

         for (int i = 0; i < 300; i++)


            s += "0123456789";


set a break point after this and display ?s at th ecommand window and cut the strin gto Wrod ir any editor that shows EOL markers and the CRLF is there???


Problem using an interval timer


The following is the script code in C# of a test web page that I created.  I discovered that "Timer(5000) refers to a time interval of five seconds.  This means that you can specify any interval by indicating how many thousandths of a second to elapse before the timer times out. 


But, my problem now is with how to display something different on the web page after the interval has elapsed.  My code initially displays a zero in a textbox.  I intended to have this change between a one and zero with each time interval.  But, I get an error that says "Response is not available in this context" when I attempt to restart this page again to display a different number with Response.Redirect ("TimerTest.aspx");  What am I doing wrong?





    protected System.Timers.Timer _timer;

    protected void Page_Init(object sender, EventArgs e)


        _timer = new System.Timers.Timer(5000); // initialize the time control

        _timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed); // subscribe to the Elapsed event


Inserting 15 minute Interval Data in a table


What is the most efficient way of creating a 15 minute increment table. This table needs to continue to increment with time so its not a static table. While loop? how will that affect the performance, if I have to add dates starting 2005 till today and then basically after that with every hour a value needs to be added.. How can I go about doing that?

I am using SQL 2008

 Thanks -Sarah

day repeated in a given time Interval


Good mornning all,

can anybody tell me how can we know that how many times a day is repeated in given time duration.

Means  if startdate "12/01/2010"  and enddate "12/31/2010"  the how can i know that between this duration how many times Sunday(or any other day) repeated.

Thanks to all.

Fetching data after every fixed interval


I have a webservice which needs to query the Database every hour to get the latest copy of the data. What would be the best way to have the websevice call a method every hour. I am condering using the Timers.Interval to call a method every hour. Has anyone implemented this before? Or, is there a better way to do it?

How do I set the Interval for a Timer control which is inside a Update control?


Hi all,

Basically I am trying to execute this code:

         <asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Enabled="True" Interval=Convert.ToInt32(ViewState["RefreshInterval"] />  


Error 1 Cannot create an object of type 'System.Int32' from its string representation 'Convert.ToInt32(ViewState["RefreshInterval"])' for the 'Interval' property.

Thank you


Sharepoint Server 2010 reloading web parts with a certain interval even when nobody use it


First of all sorry for my English, because i'm Russian.. 

I developing a Web Part for getting some Currencies Rates from Internet Source. XMLLoader class has one method Load() which loads Currency Rates data from External Source to static variable... I want this data would be downloaded at first load of SP page which consist that web part.  So I overrided OnLoad method to check if it is postback or not... (My ascx control consists UpdatePanel to recalculate currencies dependencies). 

I'm using Fiddler to debug my http requests to detect when XMLLoader.Load() method works.. (Please see this image... Http Request for www.ecb.europa.eu)


 protected override void OnLoad(EventArgs e)
 if (!Page.IsPostBack)
 XMLLoader loader = new XMLLoader();
 List_AllCurrencies = loader.Load();

 protected override void CreateChildControls()
 Control control = Page.LoadControl(_ascxPath);

Excute stored procedure on fixed time interval



My SQL Server 2008 is on the Windows Server 2008.
I have a stored procedure which is transferred from SQL 2000 (on Windows Server 2003).  Now I would like to have that stored procedure executes every 15 minutes, how do I do that in the SQL 2008/Win 2008 environment?
Thanks for help.


SharePoint 2010 backup is failing - Error - "Unable to read full interval from database - Operation



I am having a problem backing up a site collection, when trying to backup the collection I get the following error "Unable to read full interval from database" and "operation is not valid due to the current state of the object".

The backup does run and manages to backup 182MB of the site collection and then the backup fails, it fails at the same point what ever backup method I use e.g. STSADM, Powershell or Central Admin.

I'm getting the same error whether I use CA "granular backup" or "Farm backup", and using either STSAMD or Powershell. I can backup CA or the mysite collection but not the Home Portal site collection. I even tried installing the commuvaults 2010 agents and running a commuvault backup but this is also failing. i have included the log file entry below.

Does anyone have any suggestions on what i can do to either fix the problem or an alternative way to backup the collection or farm, I am currently taking a full SQL backup but am not sure how reliable this is as I haven't tried to restore the sites. 

P.S. I am not using the "UseSQLSnapshot" parameter.

11/30/2010 09:34:25.23  OWSTIMER.EXE (0x17E8)                 

MSLine chart y axis interval need to change


i got a small problem in line charts Y - Axis intervals. Scenario is like this.                  

                  there is a line-chart control where min value is '0' and max value is '100'. But my problem is we cannot predict the interval, means should be change

So y axis should be like this " 0,10,16,24,31,40.7,50,56,59,74,87,100

how to achieve this.



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend