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
 Still Dating

Author  Topic 

OBINNA_EKE
Posting Yak Master

234 Posts

Posted - 2006-09-19 : 06:10:13
Select * from myTable where datein = Convert(datetime,'19/09/2006')

In myTable I have Data that are Today and thequery above does not get it
why


If it is that easy, everybody will be doing it

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-19 : 06:22:21
Try to use ISO dateformat

Select * from myTable where datein = Convert(datetime, '20060919')


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Hariarul
Posting Yak Master

160 Posts

Posted - 2006-09-19 : 06:30:17
Try this ..

Select * from myTable where datein = Convert(varchar(10),'19/09/2006',121)
Go to Top of Page

OBINNA_EKE
Posting Yak Master

234 Posts

Posted - 2006-09-19 : 06:31:09
tHIS query is meant to be run everyday can I have

Select * from myTable where datein = Convert(datetime, getdate()) - it does not work

If it is that easy, everybody will be doing it
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-19 : 06:33:17
GETDATE() already is DATETIME datatype. You have to remember that GETDATE() also includes TIME-information.

What datatype is DateIN column?

Try this
Select * from myTable where datein = DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0)



Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -