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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 cast to datetime

Author  Topic 

kcarbone1970
Yak Posting Veteran

52 Posts

Posted - 2014-02-14 : 01:27:17
hello, I have this query where I am producing a string value in my c# code behind and for whatever reason it doesn't work so my assumptions are that the value needs to be casted or converted from string to datetime which is the destination field type. so I would greatly appreciate any help on the matter...here is my query with my poor attempt at casting which is obviously wrong.


SELECT COUNT(CASE WHEN ATT.AL IN ( 'A', 'E', 'I', 'K', 'L', 'S', 'U', 'X' )
THEN ATT.SN
END) AS [Total Absences]
FROM ATT
INNER JOIN STU ON ATT.SN = STU.SN
AND STU.SC = @SC
WHERE ( STU.ID = @ID )
AND CAST(ATT.DT AS DATETIME >= @dt1 )


Cartesian Yak

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-02-14 : 02:05:02
Please do refer to the Books On Line if you are not familiar with the syntax http://msdn.microsoft.com/en-us/library/ms187928.aspx

WHERE ( STU.ID = @ID )
AND CAST(ATT.DT AS DATETIME ) >= @dt1



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -