Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 date format is there????

Author  Topic 

under2811
Constraint Violating Yak Guru

366 Posts

Posted - 2006-09-22 : 04:55:04
hello friends

I want to search the my_date between mydate_fr and mydate_to
but i am getting my_date from front end is like '9/12/2006' (mm/dd/yyyy)....but when i query this i am getting none records but if i manually type my_date like '09/12/2006' then i am getting records..how should i proceed..my query is

SELECT *
FROM my_DownLoadfiles
WHERE '9/12/2006' >= my_date and my_date <= '9/12/2006'

T.I.A

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-09-22 : 05:01:20
use CONVERT function:

SELECT *
FROM my_DownLoadfiles
WHERE my_date between convert(datetime, mydate_fr, 101) and convert(datetime, mydate_to, 101)



Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-09-22 : 06:03:58
[code]
declare @date_from datetime,
@date_to datetime

select @date_from = '20060912',
@date_to = '20060912'

select *
from my_Downloadfiles
where my_date >= @date_from
and my_date < dateadd(day, 1, @date_to)
[/code]


KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-09-23 : 09:03:44
http://www.sql-server-performance.com/fk_datetime.asp

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -