p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   SQL Server 2000 (http://p2p.wrox.com/forumdisplay.php?f=20)
-   -   how to convert date to days (http://p2p.wrox.com/showthread.php?t=57602)

teamml May 8th, 2007 06:31 AM

how to convert date to days
 
Hello

Is it possible to convert date to days from 01-01-1900
to date = number of days in a SQL statment ???
 ex from 01-01-1900 to 01-01-1901 = 365 days

The format is dd-mm-yy
Regards ml




happygv May 8th, 2007 06:38 AM

Do you define the start and end dates to calculate the number of days? If so
Code:

DECLARE @StartDate datetime, @EndDate datetime
SET @StartDate = '2007-01-01'
SET @EndDate = '2007-05-01'

SELECT DateDiff(d, @StartDate, @EndDate)

Which returns 120. Does this helps?

Cheers

_________________________
- Vijay G
Strive for Perfection

teamml May 8th, 2007 06:49 AM

Thanks it was the DataDiff in SQL.
Du you know a link to find SQL statements Like DateDiff ??


happygv May 8th, 2007 07:05 AM

Check Books online (BOL) for "Date Functions".

_________________________
- Vijay G
Strive for Perfection


All times are GMT -4. The time now is 04:21 AM.

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