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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Time Difference in Linq queries

Posted By:      Posted Date: August 24, 2010    Points: 0   Category :ASP.Net

Hi All,


I have my Linq query in which i need to find time difference(not days difference).

The field in database is datetime.

Dim ldtToday As DateTime = TimeOfDay

Dim SR_RM_InnerJoin = From SR In lcntxRT60Entities.RtSReports _

Join RM In lcntxRT60Entities.RtRMaster On SR.RtRMaster.ReportID Equals RM.ReportID _

Select SR, RM _

View Complete Post

More Related Resource Links

Which tier do Linq queries belong?


Started in middle of a new project.  Our design architecture uses an n-tier (not MVC - no controllers) structure with Presentation, Data, Business and Service tiers.  However the lead analyst has the majoriety of code all in the Business tier claiming it all contains Business logic.  Our data tier is nothing more than a single .dbml model of the primary database to support all of the Linq queries in the Business tier.  To my mind Linq queries and classes they use are data access and belong in the data tier  but our lead analyst says they contain business logic therefore have to be in business layer.  

Data Points: LINQ Projection Queries and Alternatives in WCF Services


LINQ's ability to project randomly shaped data into anonymous types can be a blessing and a source of frustration, says Julie Lerman. It's great when you just need to grab a special view of your data, but it can be problematic in certain circumstances. She explains what the limitations are and how to get around them.

Julie Lerman

MSDN Magazine May 2010

Data Points: Precompiling LINQ Queries


Did you know that by precompiling LINQ queries you might actually be degrading your app's performance if you're not careful? Julie Lerman explains how to ensure you're not re-precompiling queries each time and losing the expected performance benefits across post-backs, short-lived service operations and other code where critical instances are going out of scope.

Julie Lerman

MSDN Magazine March 2010

Toolbox: Easy LINQ Queries, Becoming A Better Developer, And Logging Help


This month Toolbox provides help with error logging, finds an app that helps you write LINQ queries, and explores the non-technical side of development.

Scott Mitchell

MSDN Magazine September 2008

Parallel LINQ: Running Queries On Multi-Core Processors


Use Parallel Language Integrated Query (PLINQ) to take advantage of multi-processor computers and the newer wave of multi-core processors.

Joe Duffy and Ed Essey

MSDN Magazine October 2007

Time difference : Hosting Server and client

hi All,I have asp.net/c# web project. How to manage the time difference between the server and clientFor instance, I am at India, and Server is located at UK. So if do any activity, like "comment on friend's photo" etc. the time stamps is UK's time. So if do some activity from India at 10.00 AM, the time stamp would be 5.00 AM. So if the user who sees his activity at 10.00 AM sees it as if it was done at 5.00 AM.If user whom he acted upon (like friend whose photo got the comment) too see 5.00 AM. this is ok if the friend is at UK, but causes confusion if he was at other time location like Australiahow to handle this

Time Difference

Hi frends,              I have used four dropdownlist, and one Textbox. dropdownlist contains  Hour(StartingTime,EndngTime ) and min(StartingMin and EndingMin), both are in 24 hours format..Now I want to calculate the Time difference between 2 times.I tried, but not working properly. int _startintime = int.Parse(dropdownlistSHour.SelectedValue); int _endingTime = int.Parse(dropdownlistSMin.SelectedValue); try { DateTime begin = new DateTime(); DateTime end = new DateTime(); begin = begin.AddHours(double.Parse(dropdownlistSHour.SelectedValue)); begin = begin.AddMinutes(double.Parse(dropdownlistSMin.SelectedValue)); end = end.AddHours(double.Parse(dropdownlistEHour.SelectedValue)); end = end.AddMinutes(double.Parse(DropDownListEMin.SelectedValue)); TimeSpan ts; ts = begin.Subtract(end); textboxDuration.Text = ts.ToString(); }

Visual studio 2005 - Port Number is difference during run time.

Hi, When I debug(F5), the port number display in the URL is difference from the ASP.net development server. Eg: URL address port number is  - 1084, while for the Server is 1088 I have tried difference ways such as trying to set the dynamic port to false, so that I can configure my own port, but it is not able to work. I have also turned off the ESet Firewall however the port number is still difference.  Need your help in this area.. Thank you! 

Convert the Sql query to LINQ .. can anyone please help me I need it ASAP as no time to learn and im

 SELECT DISTINCT HP.PartNumber, HP.MIRevision, HPEXData.InstructionImage, EXAttr.PlacementImage from dbo.HardwareParts HP   INNER JOIN dbo.HardwarePartEXData HPEXData     ON HP.HardwarePartID = HPEXData.HardwarePartID   LEFT JOIN dbo.EXMIAttributes EXAttr    ON EXAttr.EXTypeID = HPEXData.EXTypeID   WHERE    HP.PartNumber = @PartNumber     AND REPLACE(SUBSTRING(HP.MIRevision, 1, 13),'.','') >= REPLACE(SUBSTRING(ISNULL(@PartRevision,''), 1, 13),'.','')    AND ISNULL(HP.ProjectID,'') = ISNULL(@SINumber,'')    AND (@ChassisIdentifier IS NULL OR HPEXData.EXMI_Type NOT IN ('Add In Card','Storage') OR EXAttr.ChassisIdentifier = @ChassisIdentifier)   END;anji

Join linq queries with same field name

Hi everyone-I'm trying to join three Linq queries together.  One of the fields (rating) is the same name for each so when I add b.rating as you'll see below, I get a squiggly that says "Anonymous type member or property 'rating' is alread declared.   Dim customerCategoryA= (From a In dc.CategoryARatings _                                  Where a.userID = userID _                                  Select New With {a.productID, a.rating, a.ratingComment}) Dim customerCategoryB = (From b In dc.CategoryBRatings _                                 Where b.userID = userID _                                 Select New With {b.productID, b.rating}) Dim DataForGridview = From p In Products _   

Asynchronously Load LINQ Queries/Repeaters in Sections with Web Service



I'm trying to  figure out the best way to load my main page faster.  What I'd like to do is have the bare bones of the master page display right away and on the Default.aspx Page_Load, call some web services that would query the rest of the items, in chunks, and then display.  I have 3 or 4 queries, which would be the chunks I am talking about. 

How would I accomplish this?  I tried putting Update Panels around the repeaters, but that didn't make the page show any faster, and the page still only displayed once all the data was queried.

I found this article, http://msdn.microsoft.com/en-us/library/2e08f6yc.aspx.  Could I call a web service and return a Linq Query and populate a Repeater on Default.aspx?  Would I need an Update Panel around the Repeater still?

I also found this article, which was very interesting in that it parsed and returned the actual HTML to plug into the page, http://encosia.com/2008/02/05/boost-aspnet-performance-with-deferred-content-loading/

I've been reading both of these for a while to try to understand which may be the best method to proceed with.  I'd really appreciate any a

epased time for few SQL queries is 0 in sys.dm_exec_query_stats table?



I get the elapsed time from sys.dm_exec_query_stats table for each SQL query that I run in MSSQL. I see that the elapsed time for some of the SQL queries are shown as 0 while oracle performance statistics data show some time for the same query.

I believe MSSQL can't take 0 microseconds to execute a query. Should I need to force MSSQL to monitor the lesser time taking queries?

I also used "SET STATISTICS TIME ON", I get 0 elapsed time from this too for those queries which had 0 elapsed time from sys.dm_exec_query_stats.

Any help will be helpful

How to check time difference between two SQL 2008 servers



I have multiple SQL server and want to ensure time is sync between them.

All the servers have common SNTP.

But I want to check the sync.


Any options to try are welcome.

sql server maintenance plan schedule time and execution time difference


Hi All,

One of my customer db there is one maintenance plan(full backup / Transaction log backup  ) schedule time for the full backup is 11:00:00 PM daily and for transaction log backup 12.30 pm Sunday to Friday ,I checked the job created by maintenance plan there also schedule time is same but when i check the history of the job it shows it happened at 7:00:00 pm every day. why there is time difference ?

Product version is 8.00.2055(SP4)

i checked the MSDB.dbo.sysjobschedules table and the next_run_date is not updated properly,it is showing yesterday 11:00:00 pm


please help me to resolve this issue




can sql queries work on the same form with Linq queries



I have a windows form with VB  and SQL database ,and i find that once i have written some Linq queries that the SQL queries do not work anymore . Is there any reaon for this and if so how can i overcome it?

THanks Rob


Can LINQ be used with sql queries



I have a windows form with VB  and SQL database ,and i find that once i have written some Linq queries that the SQL queries do not work anymore . Is there any reaon for this and if so how can i overcome it?

THanks Rob


How to retrive a date time value from TimeStamp column using Linq?


I have a Timestamp column in my Table. I want to read the date time value and display in UI.

In Linq the Timestamp column is represented as System.Data.Linq.Binary.

I dont know how to retirve date time value in "MM-dd-YYYY" format from this Linq.Binary


- Why I am using Timestamp?.

I want to perform some operations based on the last modified date time of the particular row. Since I am using TimeStamp column in my Table as version column, It will contain the last modified date details, So i want to read the date time value from this time stamp column to do some other operations.



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