草庐IT

日期差

全部标签

c# - 在 C#、.Net 4.0 中解析 RFC1123 格式的日期

我正在尝试解析RFC1123格式的日期(美国东部时间2010年1月21日星期四17:47:00)。这是我尝试过但没有奏效的方法:DateTimeDate=DateTime.Parse(dt);DateTimeDate=DateTime.ParseExact(dt,"r",null); 最佳答案 你有没有试过这样的事情:stringdateString,format;DateTimeresult;CultureInfoprovider=CultureInfo.InvariantCulture;dateString="Thu,21Jan

c# - 使用日期时间列设置 LinqDataSource Where 子句

在C#.net中,我有以下数据源设置,我试图在后面的代码中动态分配一个WHERE子句...后面的代码看起来像这样......LinqDataSource1.Where="MyDateColumn==DateTime("+DateTime.Now+")";这给了我')'or','expected的错误。我也尝试过将它转换到引号内,就像不将它转换为DateTime和带引号一样......LinqDataSource1.Where=@"MyDateColumn=="""+DateTime.Now+@"""";这给我Operator'=='incompatiblewithoperandtype

c# - Convert.ToDateTime 在下午日期/时间值上导致 FormatException

我们有一个应用程序解析以下格式的日期/时间值:2009-10-1009:19:12.1242009-10-1012:13:14.8522009-10-1013:00:002009-10-1015:23:32.022一个特定的服务器突然(今天)在13:00:00或更晚的任何时间开始解析失败。这个特定的客户端有五台服务器,只有一台有问题。我们有几十个其他客户,总共有数百台服务器没有问题。System.FormatException:StringwasnotrecognizedasavalidDateTime.atSystem.DateTimeParse.Parse(Strings,Date

c# - 在 Visual Studio 片段中插入当前日期时间

有谁知道我可以在visualstudio2008片段中插入当前日期和时间的方法吗?我想要的是我的.snippet文件正文中的类似内容... 最佳答案 没有可用于片段的DateTime函数,但这里有一个将插入当前DateTime的宏:SubPrintDateTime()If(NotIsNothing(DTE.ActiveDocument))ThenDimselectionAsTextSelection=DTE.ActiveDocument.Selectionselection.Insert(DateTime.Now.ToString(

c# - 如何在 C# 中将日期与 'T' 转换为字符串/从字符串转换

我使用以下函数将DateTime从string转换为/转换为string:DATE_OBJ.ToString(DATE_FORMAT);DateTime.ParseExact(Date_string,DATE_FORMAT,null);现在我必须使用以下格式2012-03-20T14:18:25.000+04:00我应该使用哪种格式将其正确转换为string并从DateTime对象生成string? 最佳答案 您可以使用从DateTime转到该格式DateTimedt=newDateTime();dt.ToString("o");并

c# - 如何在 app.config 文件中写入日期?

很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visitthehelpcenter.关闭10年前。我需要能够在app.config文件中定义一个日期。我如何执行此操作然后使用C#检索它?

c# - 使用 linq-to-entities 将字符串转换为日期时间的大问题

如何使用linqtoentities将字符串转换为日期时间....我有下面的查询,其中visit_date列数据类型是字符串...varmemberl=fromvinabc.visitsjoinminabc.membersonv.member_Idequalsm.member_IdwhereConvert.ToDateTime(v.visit_Date)>=startdate&&Convert.ToDateTime(v.visit_Date)很遗憾,我无法更改架构...我遇到了错误:linqtoentitesdoesnotrecogniseConvert.ToDatetimemetho

c# - 如何通过示例在 C# 中格式化日期?

C#在为字符串表示形式格式化DateTime对象时提供了很大的灵active,但是,必须了解所有格式字符串才能使用这种灵active。如果你想以“Fri,June24”的形式显示日期,你可以这样做:DateTimesomeDate=DateTime.Now;Console.Write(someDate.ToString("ddd,MMMMdd"));虽然这很有效,但对于更复杂的格式来说很难,尤其是对于第一次使用它的开发人员而言。我想获得与上面代码返回的相同结果,但是要这样:DateTimesomeDate=DateTime.Now;Console.WriteLine(someDate.

c# - 比较相等的日期时间返回 false

我有一个关于如何在C#中比较/存储日期时间的问题。考虑以下代码:varcreatedDate=DateTime.Now;using(cr=newLanguageDictionaryRepository(ds)){cr.Add(newSybrin10.Data.DTO.LanguageDictionary(){Active=true,CreatedDate=createdDate,CultureCode=cultureCode,Data=newSystem.Text.UTF8Encoding().GetBytes("Test")});cr.Save();vary=cr.FindBy(x=

C# DateTime ToString ("MM-dd-yyyy") 返回有趣的日期值

我在ASP.Net页面的代码隐藏文件中有以下代码txtStartDate.Text=DateTime.Today.ToString("MM-dd-yyyy");我希望返回“09-11-2009”。但是,当我在开发服务器上运行该页面时,我在文本框中看到“09-00-2009”。我看不出有任何原因,所以我显然遗漏了一些东西。有人知道吗? 最佳答案 我不明白为什么它会显示00,但作为一个随机建议,您可以尝试:...=DateTime.Today.ToString("MM-dd-yyyy",CultureInfo.InvariantCult