Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
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 May 8th, 2007, 06:31 AM
Registered User
 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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



 
Old May 8th, 2007, 06:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
 
Old May 8th, 2007, 06:49 AM
Registered User
 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old May 8th, 2007, 07:05 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
date conversion in years, months and days naveed77 Beginning VB 6 0 January 2nd, 2008 01:18 AM
Todays date and date of 3 days later Singh591 Visual Basic 2005 Basics 1 December 21st, 2006 06:06 PM
How to calculate a number of days between 2 date windy417 Pro JSP 1 July 20th, 2006 07:09 PM
convert to days khautinh SQL Server 2000 4 September 8th, 2005 02:09 PM
Can't subtract days from a date Please Help Arsi C# 1 January 6th, 2005 03:34 PM





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