dateTime フィールドからタイムスタンプを削除しようとしています。
int[] projects = {11157, 11138};
protected void compare(System.Data.DataTable dt1, System.Data.DataTable dt2, int[] arr)
{
differences.Columns.Add("ID", typeof(int));
differences.Columns.Add("BRS Date", typeof(string));
foreach (int value in arr)
{
DataRow[] result = dt1.Select("ChangeRequestNo = '" + arr +"' OR [GPP ID] = '" + arr + "'");
string brs = "";
string srs = "";
if (result.Length > 1)
{
DataRow row1 = result[0];
DataRow row2 = result[1];
DateTime row1date = (DateTime)row1[2];
DateTime row2date = (DateTime)row2[10];
//Remove the Time stamp on the dateTime
//variable coming from the GPP Extract
//row2date.cast(floor(cast(getdate() as float)) as datetime);
if (row1date.Equals(row2date))
{
// find your Image control in the Row
//Image image = ((Image)differences.Rows[1].FindControl("img"));
// set the path of image
//img.ImageUrl = "path of image";
brs = "True";
}
この質問は、SQLserver を介して尋ねられた可能性がありますが、何か間違ったことをしていない限り (ほとんどの場合)、C# では機能しません。
SQL Server で日時を切り捨てるにはどうすればよいですか?
基本的に、変数に入る値は「9/12/2008 12:00:00 AM」で、「9/12/2008」が必要です。キャスト演算子のいくつかのバリエーションを使用しましたが、うまくいきませんでした。
CAST(BRSDate AS Date) -> Does nothing
CAST(BRSDate AS varchar(11)) -> 2009-05-26 and some dates come out as 0001-01-01
再投稿して申し訳ありませんが、見つけた解決策は残念ながら機能しません=(.誰か助けてくれますか?