我希望从 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#,除非我做错了什么(很可能):
基本上进入我的变量的值是“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
我为重新发布道歉,但不幸的是我找到的解决方案对我不起作用=(。有人可以帮忙吗?