Wrox Programmer Forums
|
BOOK: Professional SQL Server 2000 Programming
This is the forum to discuss the Wrox book Professional SQL Server 2000 Programming by Robert Vieira; ISBN: 9780764543791
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional SQL Server 2000 Programming 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 December 7th, 2005, 11:23 PM
Registered User
 
Join Date: Dec 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default DateTime in SQL Server 2000

I'm new to SQL Server 2000 and have a question about DateTime. I'm more comfortable with Access and how it handles dates. I use a # for dates there. Also I never had the actual time in the field either. Now I have a table in SQL Server with date and time. I try to run a query with just date but it doesn't work. How can I convert this field to just date, or what function can I use in my query to just look at the date and ignore the time? Thanks.

 
Old December 8th, 2005, 11:13 AM
tbj tbj is offline
Registered User
 
Join Date: Sep 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello RickP,

I suggest first you run following small script in query analyzer and see the result. Then look up help On function CONVERT. Also read topic 'Truncating the time from a datetime field' on page 372 of the book and you will not have any problem with datetime field in sql Server 2000 again.

Hope this helps.
tbj

declare @todaysDate DateTime
declare @ConvertedDate datetime
declare @aDate datetime

set @aDate = '12/05/2005'
set @todaysdate = getdate()
set @converteddate = convert( datetime, convert(varchar(12), @todaysdate, 111))

print 'getdate = ' + cast(getdate() as varchar)
print ' todays date = ' + convert(varchar(12), @todaysdate, 111)
print 'Converted date = ' + convert(varchar(12), @converteddate, 111)
print 'aDate = ' + convert(varchar(12), @aDate, 111)

print ' (varchar-10) todays date = ' + convert(varchar(10), @todaysdate, 111)
print ' (varchar-10) Converted date = ' + convert(varchar(10), @converteddate, 111)

go





Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Server 2000 and SQL Server 2000 CE dparsons SQL Server 2000 1 July 31st, 2006 12:59 PM
Sql Server DateTime field Vs ASP itHighway SQL Server ASP 2 August 16th, 2005 02:38 PM
ASP, Sql Server DateTime field itHighway Classic ASP Basics 1 August 14th, 2005 06:32 PM
looking for access 2000 to sql server 2000 sql/que method SQL Server 2000 0 July 7th, 2005 12:46 PM
SQL SERVER 2000 AND ACCESS 2000 ckentebe SQL Server 2000 3 June 17th, 2004 08:50 PM





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