how to convert datetime to string in linqtosql?
Posted
by kwon
on Stack Overflow
See other posts from Stack Overflow
or by kwon
Published on 2010-06-16T10:38:56Z
Indexed on
2010/06/16
10:42 UTC
Read the original article
Hit count: 345
linq-to-sql
I am using linqtosql and inside of linq query, I tried to convert datetime type column to string like 'dd-MM-yy'. However, I got error as following :
NotSupportedException: Method 'System.String ToString(System.String)' has no supported translation to SQL.
following is my linq query :
from ffv in Flo_flowsheet_values
where ffv.Flowsheet_key == 2489
&& ffv.Variable_key == 70010558
&& ffv.Status == 'A'
&& ffv.Column_time >= DateTime.ParseExact("2010-06-13 00:00", "yyyy-MM-dd HH:mm", null)
&& ffv.Column_time <= DateTime.ParseExact("2010-06-13 22:59", "yyyy-MM-dd HH:mm", null)
select new {
ColumnTime = ffv.Column_time
,ColumnTimeForXCategory = ffv.Column_time.Value.ToString("dd-MM-yy") ***====> this statement invoke error***
,BTValue = Convert.ToDouble( ffv.Value) }
what is problem?
Thanks in advance
© Stack Overflow or respective owner