Question DateDiff query

mkkb917

Member
Joined
Nov 24, 2012
Messages
18
Location
Pakistan
Programming Experience
Beginner
how to use datediff in my query to get the difference between two time form the table i wrote a query but its may have some errors and not working
VB.NET:
  Select [Date],[TimeIn], [TimeOut], DateDiff(m, TimeIn, TimeOut) as Duration from [dbo].[Logs] WHERE PhoneNo = '"+lblphoneno.text+"'"
i am using sql express with VS 2010 i want to get these columns and trying to display them in the DGV on the form thanks
 
Unless you're trying to get the number of months between the two times, you'll have better luck using mi instead of m as the 'datepart' parameter.

e.g

VB.NET:
...DATEDIFF(mi, TimeIn, TimeOut)...

DATEDIFF (Transact-SQL)
 
i wrote a query but its may have some errors and not working
If only there was some way for us to know what those error were and what actually did happen. I know... you could tell us!
 
I just executed your SQL code in Management Studio and it executed without issue, with a change to the value for PhoneNo of course. Can you execute it in Management Studio?
 
Back
Top