Wrox Programmer Forums
SQL Server 2008 General discussion of SQL Server *2008* version only - not related to a specific book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2008 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 July 21st, 2012, 04:26 AM
Authorized User
Join Date: Dec 2009
Posts: 85
Thanks: 16
Thanked 0 Times in 0 Posts
Default date time field

Hi there

I've got 2 x sql statements - the first one I want to pull out records between certain date ranges, the second I want to pull out records after their end date has passed.

This is what I've got set up for pulling out the records between certain date ranges:

SELECT * FROM tbl_tenders t WHERE t.startdate <= 21/07/2012 AND 21/07/2012 <= t.enddate AND IsLive = 0 ORDER BY t.startdate DESC

For the records whose enddate have passed I have:

SELECT * FROM tbl_tenders t WHERE 21/7/2012 > t.enddate

the enddate field I have in the database is a datetime field written such as: 2012-07-19 00:00:00.000 though not sure this should make any difference

What's happening is that all the records are being shown using the first sql statement regardless of the date

can any one advise?


Old July 22nd, 2012, 06:38 PM
Friend of Wrox
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41

please try not to waste peoples time by posting in more than one area, I have given you some of my time here:

date field
Wind is your friend

Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Time Field not displaying Date and Time webmeister Access 2 January 31st, 2011 12:49 AM
Null Value for Date/Time Field ksegars4 Crystal Reports 2 November 17th, 2004 11:58 AM
SQL2000 Date/Time field update Lucian Ion Dreamweaver (all versions) 9 January 2nd, 2004 09:14 PM
Format Date to time field KennethMungwira VB.NET 3 November 17th, 2003 11:48 AM
Displying Date/time inside a text field spraveens HTML Code Clinic 1 November 14th, 2003 12:06 PM

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