469,150 Members | 1,912 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,150 developers. It's quick & easy.

subtracting 2 datetime values

2
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 1904
ck9663
2,878 Expert 2GB
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
tomcbr
2
I am a little unsure what you mean by “column that links the two”
Basically I need to subtract the first query’s "originalAlarmTime" from the second query’s "originalAlarmTime".

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

Post your reply

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

Similar topics

6 posts views Thread by Thomas Bartkus | last post: by
1 post views Thread by Shai Zohar | last post: by
1 post views Thread by Bruce Vander Werf | last post: by
2 posts views Thread by Joe Van Meer | last post: by
4 posts views Thread by David S. Alexander | last post: by
5 posts views Thread by A.M | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.