Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Querying Dates problem 4

Status
Not open for further replies.

Modica82

Technical User
Jan 31, 2003
410
GB
Hi All,

I have a column that stores dates:

21/07/2004 13:13:52

but when i try and query this like so:

SELECT * FROM tblTable1 WHERE DateColumn = 21/07/2004

nothing is returned,

Any ideas??
 
Try this:

SELECT * FROM tblTable1 WHERE Convert(varchar(10),DateColumn,103) = '21/07/2004'

-VJ
 
Thanks amorous, it worked. I have queried dates like this before i swear i have! hmm! :)

Rob
 
Hey Rob,

i believe you...I too had tough times with the queries involving dates...

I am glad that it worked for you...[2thumbsup]

-VJ
 
I am having a query problem with dates as well. I am basically new to Programming. I know how to set criteria for a search, but what I want is more difficult at least for me.
I have a table that stores Dates I need a query to return, lets say only 4-1-01 through 7-31-01 for the years 2001-2004. If i use a between statement i get everything in between. If you have any Ideas I would greatly appreciate it.
 
For jmw713,

Looks like you are trying to query Q2?

How about:
Code:
Select *
  From MyTable
 Where DatePart(q, MyDate) = 2
   And Year(MyDate) Between 2001 And 2004
HTH,
John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top