Getting total minutes from two date fields.

Hello Experts,

I have the following Select Statement:


SELECT tblOutage.Case_ID, AST_OutageLog.OutageStartDate, AST_OutageLog.OutageEndDate, Format([AST_OutageLog.OutageEndDate]-[AST_OutageLog.OutageStartDate]) AS OutageMinutes, tblOutage.Assigned_To_Group, tblOutage.Priority, tblOutage.Status, tblOutage.CreateTime, tblOutage.ResolvedTime, tblOutage.OutageFlag, tblOutage.Summary, tblOutage.Package
FROM tblOutage INNER JOIN AST_OutageLog ON tblOutage.Case_ID = AST_OutageLog.Case_ID
WHERE Some conditions;

Within this statement I need to get the outage minutes which is the difference between OutageEndDate - OutageStartDate. I have tried using format as you can see but this not returning what I expected.

OutageStartDate = 2/8/2008 7:00:00 AM
OutageEndDate = 2/8/2008 9:34:00 AM
OutageMinutes = 154 minutes
The query is returning 0.106944444443798      

Any Ideas?
eddiepardonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ee_rleeCommented:
try this

SELECT tblOutage.Case_ID, AST_OutageLog.OutageStartDate, AST_OutageLog.OutageEndDate, datediff('n',[AST_OutageLog.OutageEndDate],[AST_OutageLog.OutageStartDate]) AS OutageMinutes, tblOutage.Assigned_To_Group, tblOutage.Priority, tblOutage.Status, tblOutage.CreateTime, tblOutage.ResolvedTime, tblOutage.OutageFlag, tblOutage.Summary, tblOutage.Package
FROM tblOutage INNER JOIN AST_OutageLog ON tblOutage.Case_ID = AST_OutageLog.Case_ID
WHERE Some conditions;
0
eddiepardonAuthor Commented:
This works but it displays it as a neg number -154. How can I make it show just 154?
0
Aneesh RetnakaranDatabase AdministratorCommented:
use
DATEDIFF(mi, OutageStartDate ,OutageEndDate  )
0
ee_rleeCommented:
SELECT tblOutage.Case_ID, AST_OutageLog.OutageStartDate, AST_OutageLog.OutageEndDate, datediff('n',[AST_OutageLog.OutageStartDate],[AST_OutageLog.OutageEndDate]) AS OutageMinutes, tblOutage.Assigned_To_Group, tblOutage.Priority, tblOutage.Status, tblOutage.CreateTime, tblOutage.ResolvedTime, tblOutage.OutageFlag, tblOutage.Summary, tblOutage.Package
FROM tblOutage INNER JOIN AST_OutageLog ON tblOutage.Case_ID = AST_OutageLog.Case_ID
WHERE Some conditions;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
eddiepardonAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.