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
 Help with DATE() function please ?

Author  Topic 

globus71
Starting Member

2 Posts

Posted - 2011-06-16 : 04:53:48
Hi,

I'm a real newbie at this stuff and would really appreciate what's going wrong here.

The following statement is run on SQL 2008 server

select distinct FirstName,LastName from MyTable where date1='" . date("Y-m-d") . "'

returning the error "Conversion failed when converting date and/or time from character string."

The date1 column is in a datetime format.


Would really appreciate a pointer if poss?

Thanks

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-06-16 : 05:19:55
What are you trying to do?
maybe
select distinct FirstName,LastName from MyTable where datediff(dd,date1,getdate()) = 0


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-06-16 : 05:37:44
@Globus71: Why do you use some kind of PHP syntax?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

globus71
Starting Member

2 Posts

Posted - 2011-06-16 : 05:46:32
Thanks guys.

Yes, this is being run from a PHP script.

Anyway, the getdate() stuff worked OK.

Thanks for your help :)

Go to Top of Page
   

- Advertisement -