473,461 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to get the Datediff between two fields

347 100+
I'm trying to get the datediff (in minutes) between two fields in a database. These fields are going to be supplied by an end user so they can be any number or any day. The two fields are starttime and endtime and the table name is Exceptions. Can anyone offer a way to do this? I'm using SQL 2000.

Thank you,

Doug
Nov 1 '10 #1

✓ answered by dougancil

I figured this out .... here is the syntax that I have:

Expand|Select|Wrap|Line Numbers
  1. SELECT datediff(minute, starttime, endtime)  as duration from Exceptions2
  2. where exceptiondate between '5/1/2010' and '5/15/2010'
  3.  

4 3557
gpl
152 100+
Books online gives you the syntax
its along the lines of
Expand|Select|Wrap|Line Numbers
  1. Select 
  2. DateDiff(mm, starttime, IsNull(endtime, starttime))
  3. From Exceptions
Nov 2 '10 #2
dougancil
347 100+
When I run that query I get a value of 0 in all fields. I know that this can't be right.

here's the query I have:

Expand|Select|Wrap|Line Numbers
  1. Select 
  2. DateDiff(m, starttime, IsNull (endtime, starttime))
  3. From Exceptions2
  4.  
Nov 2 '10 #3
dougancil
347 100+
I figured this out .... here is the syntax that I have:

Expand|Select|Wrap|Line Numbers
  1. SELECT datediff(minute, starttime, endtime)  as duration from Exceptions2
  2. where exceptiondate between '5/1/2010' and '5/15/2010'
  3.  
Nov 2 '10 #4
gpl
152 100+
Doug
yup, you spotted the problem - mm means minute in time, but month in datediff and datepart

sorry for the bum steer
Graham
Nov 2 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Paolo | last post by:
I am having some problem with a Year Function. I have form on which I have 4 field which indicate dates and an additional form which sums those dates: These are the fields: YEARS...
1
by: Miguelito Bain | last post by:
hi everybody. i'm trying to find out what you can and can't do with/in calculated fields. any help, pointers, and/or advice would be greatly appreciated. i'm a newbie, but i want to learn, and...
1
by: info | last post by:
Can some one show me how to use the datediff function where the dates are being supplied through an access db. For instance, a recordset would contain these fields: DateAssigned, DateDue,...
4
by: perryche | last post by:
4 Fields: Date1 Time1 Date2 Time2 How do I calculate days/hours diff between Date1Time1 & Date2Time2? e.g. 3days 12hours If it were 05/02/05 11pm and 05/03/05 8am? It should say...
3
by: T23Ij9 | last post by:
Hi. I have 3 seperate date fields. InitialDate InspDate ReportDate I am trying to setup several unbound Text boxes in a form that will give me days elapsed between these dates. These text...
1
by: John T. | last post by:
I have two date fields: InitialDate InspDate I've tried to use a Datediff expression within an IIF function (see below) in an unbound textbox to give me the amount of days elapsed between...
2
by: rdraider | last post by:
Hi, We have a lame app that uses 2 datetime(8) fields, 1 stores the date, the other the time. example query: select aud_dt, aud_tm from orders results: aud_dt ...
3
by: Dinesh | last post by:
Hi Experts, I am working on SSRS 2005, and I am facing a problem in counting the no of days. My database has many fields but here I am using only two fields They are Placement_Date and...
6
by: Wheeler2008 | last post by:
Hi All, I am currently running a query on a MS Access table, in which I want to be able to compare and total the difference in dates between records. I only have one date field within the table. ...
9
geraldinegrieve
by: geraldinegrieve | last post by:
I have a table in access that holds data on vehicle there are 3 fields holding dates on MOT, Tax and Insurance renewal I am looking for 3 different messages on opening if date of any is within next 2...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.