?
Solved

DB2 SQL Date Difference in hours

Posted on 2009-04-28
7
Medium Priority
?
1,131 Views
Last Modified: 2012-08-13
How to find the difference between two dates in Hours ?
Note: the dates are in Date data type, not timestamp.

Thanks

Joseph


0
Comment
Question by:Yossele
  • 4
  • 2
7 Comments
 
LVL 37

Expert Comment

by:momi_sabag
ID: 24252072
do you have also minutes?
how do you want to round minutes to hours?
0
 
LVL 37

Expert Comment

by:momi_sabag
ID: 24252134
try
TIMESTAMPDIFF(8,CHAR(TIMESTAMP(first_date) -    TIMESTAMP(first_date)))
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Yossele
ID: 24252159
No, I don't have either hours, minutes, or seconds; just plain date.
It is just a date not a datetime ,
I guess what I am rather looking for is numbers of days

Thanks

Joseph


0
 
LVL 18

Accepted Solution

by:
Dave Ford earned 2000 total points
ID: 24252189

How about this?

24 * (days(date2)- days(date1))
0
 

Author Closing Comment

by:Yossele
ID: 31575529
this solution reflect the KISS "Keep ItSimple and Simple"
Thanks
Joseph
0
 
LVL 37

Expert Comment

by:momi_sabag
ID: 24252507
this soltion would have worked also
TIMESTAMPDIFF(8,CHAR(TIMESTAMP(first_date) -    TIMESTAMP(first_date)))
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question