Home arrow SQL Server arrow Page 4 - How to Search for Date and Time Values Using SQL Server 2000
SQL SERVER

How to Search for Date and Time Values Using SQL Server 2000


SQL ServerBefore you can effectively query date/time (or temporal) data, you have to know something about how date/time values are stored.  In this article, Bryan demonstrates the various ways in which to query an SQL Server to successfully retrieve the records you may be seeking.

Author Info:
By: Bryan Syverson
Rating: 4 stars4 stars4 stars4 stars4 stars / 122
December 04, 2003
TABLE OF CONTENTS:
  1. · How to Search for Date and Time Values Using SQL Server 2000
  2. · How Dates and Times are Stored in SQL Server
  3. · Date/Time Values are Approximate Numerics
  4. · Dates Without Times and Times Without Dates
  5. · The Effect of Database Design on Querying
  6. · Performance Considerations in Querying
  7. · How to Search by Date
  8. · How to Search by Time

print this article
SEARCH DEVARTICLES

How to Search for Date and Time Values Using SQL Server 2000 - Dates Without Times and Times Without Dates
(Page 4 of 8 )

SQL Server doesn’t provide data types for storing just the date or just the time. So if you store a date/time value without an explicit time, the fractional portion of the value is set to zero. This represents midnight as 00:00:00. Similarly, if you store a date/time value without an explicit date, the integer portion of the value is set to zero. This represents the date January 1, 1900. To see this, submit the following query:

SELECT CAST('1900-01-04' AS datetime), CAST('10:00' AS datetime)

which returns the following result:

1900-01-04 00:00:00.000              1900-01-01 10:00:00.000

Whether you can ignore the date or the time component when you query a date/time column depends on how the column has been designed and used.


blog comments powered by Disqus
SQL SERVER ARTICLES

- Executing SQL Server Stored Procedure from P...
- How to Search for Date and Time Values Using...
- Replication: SQL Server 2000 - Part 2
- Replication: SQL Server 2000 - Part 1
- SQL Sever: Storing Code in Binary or Text Fi...
- Execute SQL on Multiple Tables/Columns - New...
- How to Connect to a SQL Server from Visual F...
- SQL Server Hardware Tuning and Performance M...
- Primary Key on Multiple Tables – New RDBMS C...
- Migrating from Sybase to SQL Server
- What's Best for DBAs? GUI or T-SQL Comma...
- How to Perform a SQL Server Performance Audit
- An Introduction To The Bulk Copy Utility
- SQL Server Stored Procedures 101
- Building Your First SQL Server 2000 Database

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials