September 10, 2010 at 7:17 am
Jeff,
Year = A similiar error, Error Parsing Line 1 at 29 error = (
DatePart = error Parsing line 1 at 33
I am using Northwind.sdf Employees table which has a Birthdate field for the example
cmd.CommandText = "SELECT * FROM Employees YEAR(GETDATE())"
cmd.CommandText = "SELECT * FROM Employees DATEPART(yy,GETDATE())"
September 10, 2010 at 7:29 am
Jeff,
Just entering SELECT YEAR(GETDATE()) give the error Function is not recognized by SQL Server Compact Edition of Function [Year]
Running DATEPART returned 2010
September 10, 2010 at 7:25 pm
kenkob (9/10/2010)
Jeff,Just entering SELECT YEAR(GETDATE()) give the error Function is not recognized by SQL Server Compact Edition of Function [Year]
Running DATEPART returned 2010
Then doing a little substitution in my orginal query should do the trick... (I'll let you change the DB name/schema if necessary)
SELECT *
FROM AdventureWorks.HumanResources.Employee
WHERE DATEDIFF(dd,
DATEADD(yy, -(DATEPART(yy,GETDATE())-1900),GETDATE()), --Today
DATEADD(yy, -(DATEPART(yy,BirthDate)-1900),BirthDate)
) BETWEEN 1 AND 10
--Jeff Moden
Change is inevitable... Change for the better is not.
September 12, 2010 at 10:14 am
Jeff,
After a little trouble I have got it working. When I attempted to use it as a SqlCe CommandText string surrounded by inverted commas, I was always getting an error. However, by adding the code copied directly from the web forum page into a multiline textbox it worked fine.
Thank you very much for your help.
September 12, 2010 at 9:04 pm
kenkob (9/12/2010)
Jeff,After a little trouble I have got it working. When I attempted to use it as a SqlCe CommandText string surrounded by inverted commas, I was always getting an error. However, by adding the code copied directly from the web forum page into a multiline textbox it worked fine.
Thank you very much for your help.
Thanks for the feedback, Ken. I usually end up pasting the copy from the forum into MS Word which "fixes" a lot of stuff from forums and then copy/paste to my application. Almost the same thing as you did.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply