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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with select dates

Status
Not open for further replies.

70001864

Programmer
Joined
Nov 23, 2009
Messages
5
Location
DK
hi I have a strange problem

If I want to select a date, I can do it with this select statement with succes

SELECT * FROM tbltable
WHERE (CONVERT(varchar(10), InitDate, 105) LIKE @InitDate)

BUTTT !

If I want to have a select statement >= I get all data from the database also the date before the >= date, so what am I doing wrong ??

SELECT * FROM tbltable
WHERE (CONVERT(varchar(10), InitDate, 105) >= @InitDate)

 
Do not use the varchar conversion because you will be comparing character strings not dates.

djj
The Lord is My Shepard (Psalm 23) - I need someone to lead me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top