我在比较DateTime
和CRM
中的Excel
值时遇到问题。
1. DateTime excelDT1 = Convert.ToDateTime(row[Excel.notificationdate].ToString().Trim(), System.Globalization.CultureInfo.GetCultureInfo("hi-IN").DateTimeFormat); ;
2. var excelDT2 = row[Excel.notificationdate].ToString().Trim();
3. var excelDT3 = row[Excel.notificationdate];
4. DateTime crmDT1 = Convert.ToDateTime(caseEntity.Attributes[Case.notificationdate].ToString().Trim(), System.Globalization.CultureInfo.GetCultureInfo("hi-IN").DateTimeFormat); ;
5. var crmDT2 = caseEntity.Attributes[Case.notificationdate].ToString().Trim();
6. var crmDT3 = caseEntity.Attributes[Case.notificationdate];
下面分别是输出:
- excelDT1:1/13/2020 12:00:00 AM
- excelDT2:13/01/2020
excelDT3:13/01/2020
crmDT1:12/1/2020 4:00:00 PM
- crmDT2:1/12/2020 4:00:00 PM
- crmDT3:1/12/2020 4:00:00 PM
我可以知道如何格式化上面的内容,以便可以检查它们是否为equal
吗?
谢谢。
您可以将第一和第四与public static bool Equals (DateTime t1, DateTime t2);
进行比较
var result = DateTime.Equals(excelDT1, crmDT1);