Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 18th, 2005, 12:10 AM
Authorized User
 
Join Date: Jan 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anandham
Default No of days


 hi friends,
                I have a Date.. i want to find the difference between that date & current date in days:hrs:min:sec format.. i'm a newbie to sql server..pls help me in this regard..
 thanks
 anandham

Prem Anandh P.
Ambition Never comes to an End
__________________
Prem Anandh P.
Ambition Never comes to an End
 
Old March 18th, 2005, 10:32 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

declare @startDate datetime
set @startDate = '03/12/2005 12:00:00'

declare @endDate datetime
set @endDate = '03/18/2005 12:00:00'

declare @result integer
SELECT @result= DATEDIFF( second, @startDate , @endDate )

select convert(varchar(5), @result/86400)+':'+convert(varchar(5),(@Result%86400/3600))+':'+convert(varchar(5),@Result%3600/60)+':'+convert(varchar(5),(@Result%60))



 
Old March 21st, 2005, 01:20 AM
Authorized User
 
Join Date: Jan 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anandham
Default


 hi shahchi1,
          thank u very much for the very useful code..
          It works fine..i have implemented that in my
          application..thax again for ur valuable help
 Thanks & Regards,
 anandham





Prem Anandh P.
Ambition Never comes to an End





Similar Threads
Thread Thread Starter Forum Replies Last Post
days-from-duration Dinghus XSLT 1 November 21st, 2007 04:05 AM
Last 7 Days Record prasanta2expert Access 1 October 23rd, 2006 05:38 AM
Help with sorting by days out dbartelt Access 1 November 25th, 2005 08:31 AM
convert to days khautinh SQL Server 2000 4 September 8th, 2005 02:09 PM
Days in a Month jmss66 Classic ASP Basics 3 April 11th, 2005 05:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.