473,563 Members | 2,505 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

subtracting 2 datetime values

2 New Member
I need to subtract 2 datetime values.

The values are from the same view table but 2 different rows.

The points in the table are Alarm points which are generated via an after hours push button for air conditioning. The first point is the time the alarm is first initiated and the second is the time the alarm is disabled after the after hours timer disables.

Below are the queries which I am using to retrieves each value presently.

Expand|Select|Wrap|Line Numbers
  1. SELECT LastAlarmDetailsByTime.originalAlarmTime
  2. FROM         LastAlarmDetailsByTime
  3. WHERE      (lan = 20) AND (os = 41) AND (theModule = N'i1') AND (AlarmCode = N'DI=1')
  4. ORDER BY originalAlarmTime DESC
Expand|Select|Wrap|Line Numbers
  1. SELECT LastAlarmDetailsByTime.originalAlarmTime
  2. FROM         LastAlarmDetailsByTime
  3. WHERE      (lan = 20) AND (os = 41) AND (theModule = N'i1') AND (AlarmCode = N'CDI1')
  4. ORDER BY originalAlarmTime DESC
Oct 6 '11 #1
2 2048
2,878 Recognized Expert Specialist
What is the column that link this two? Equipment ID perhaps? And your query is almost identical, too. Do you just need the value from the previous row after sorting by date?

~~ CK
Oct 6 '11 #2
2 New Member
I am a little unsure what you mean by “column that links the two”
Basically I need to subtract the first query’s "originalAlarmT ime" from the second query’s "originalAlarmT ime".

Sorry for my ignorance, I am very new to this as I am an electrician working with building management systems.
Oct 6 '11 #3

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

Similar topics

by: Thomas Bartkus | last post by:
MySQL Version 4.0.20 on a Linux server. How does one get the elapsed time between (2) DateTime values? I need the answer to the nearest minute. Is upgrading to Ver 5 with its more robust date/time functions the only solution? You can directly subtract 2 DateTime values and a long integer results. What is that number?
by: Shai Zohar | last post by:
We have encountered the following problem with DOT.NET 2003 development environment. Sometimes while debugging, we the environment does not display the values of DateTime variables and fields. Instead of the values, the environment displays the wording "{System.DateTime}", and instead of the properties of DateTime variables, the environment...
by: Echo 8 | last post by:
Is there a simple way of compare dates? I am trying to create a list of perishable stock in an inventory that is near or past its expiration date. I've tried telling it to compare a node's value with a DateTime string, but that doesn't work. I've assumed that it is easier to manipulate today's date instead of the date in my ExpireDate...
by: Bruce Vander Werf | last post by:
I need to format a DateTime in the following format: "Mmm dd hh:mm:ss" Where Mmm is the three-letter abbreviation for the month. What's the best way to do this in C#? --Bruce
by: Jonesgj | last post by:
Hi, I have connected to a SQL Server table using dataAdapter/Dataset to fill a data grid. On SQL Server a column is a DateTime datatype (its actually a 'LastLogon' column ) and has both Date and Time. However, when I retrieve the records in the data grid, only the date portion is shown. I can't see what I'm doing wrong. I followed...
by: Joe Van Meer | last post by:
Hi all, Do dates & time values always get inserted according to the user's main language setting in their browser? Like, if I had an application that somehow relied on comparing dates and times but the app spanned across a number of languages would these comparison's still work? Would the value of Now() in England being inserted into a...
by: David S. Alexander | last post by:
How can I do simple subtraction in an XSLT. I want to read a few attribute values from an XML document, calculate their difference, and transform that value to an attribute in the XML output document. My original XML is, <Dates> <Birth Year="1966" />
by: A.M | last post by:
Hi, I have a datetime value and want to format it to "June 1, 2006" shape. How can I do that? Thank you,
by: deepbright | last post by:
I'm having trouble understanding the MySQL docs on how to subtract two DATETIME values. I have two tables that have a DATETIME column. In my SELECT I am doing a JOIN to bring in both sets of rows. What I want is to subtract the DATETIME values to determine the number of seconds between their time. In the WHERE clause I also want to filter the...
by: remya1000 | last post by:
I’m using VB.net 2003 application program. I am trying to do a select statement whereby I'm searching between 2 datetime values that are being stored as datetime. records are stored inside Access. For example, I’m searching between 2 datetime So I need to find all the records in between 10:00 AM and 12:30 AM on 2/23/2009. i tried...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.