I'm using Visual Studio 2013, I try to use some function (like "cast" and Year ) in Table Adapter Query Builder (in DataSet.XSD ). I get erroe messgae every time. I run the sql statement on other sql programs and it's work fine. did anyone face this problem?
-
From the error message it looks like you are using SQLite, and `YEAR` is not a [valid SQLite DATETIME function](https://www.sqlite.org/lang_datefunc.html). – GarethD Jan 20 '16 at 12:24
2 Answers
Is your dataSource SQL Server or SQLite. If you are using SqLite then functions such as Year(),Cast() are not allowed.
If you are using SQLite then please find below link for date time function reference,
https://www.sqlite.org/lang_datefunc.html
As you have asked for Cast function, there is SO post describing the cast function, which is similar to that of SQL Server
SQLite supports CAST and:
Casting an INTEGER or REAL value into TEXT renders the value as if via sqlite3_snprintf() except that the resulting TEXT uses the
encoding of the database connection.
So you can do things like this:
select cast(some_integer_column as text) from some_table;
Or, depending on what you're trying to do, you could just treat the numbers as strings and let SQLite coerce the types as it sees fit:
select some_int || ' pancakes' from some_table; select some_int || '' from some_table;

- 1
- 1

- 340
- 2
- 9
-
I'm using SQLite, So I have to use only functions that allowed in SQLite even when I work in Visual Studio. Thanks for the link. – Khorshid Jan 20 '16 at 12:31
SQLite does not have this function YEAR(...)
. Try strftime('%Y', degrees.ExamDate) = '2017'
instead.

- 3,526
- 14
- 24
-
Yes, This function work!, what about CAST, is there are an alternative for it in sqlite? – Khorshid Jan 20 '16 at 12:29