C# 函数的作用是:返回项目转换为.net时的日期和时间
当我在Windows Server 2008 R2上工作时,我的应用程序表现不同 当我将PowerScript转换为.net项目时,today()的函数将值返回为日期和时间(日期+时间),而不仅仅是日期C# 函数的作用是:返回项目转换为.net时的日期和时间,c#,datetime,powerbuilder,powerbuilder-conversion,C#,Datetime,Powerbuilder,Powerbuilder Conversion,当我在Windows Server 2008 R2上工作时,我的应用程序表现不同 当我将PowerScript转换为.net项目时,today()的函数将值返回为日期和时间(日期+时间),而不仅仅是日期 ldt_date = today() 有什么建议吗?在.NET中,您可以使用 就像 yourdate.ToString("d") 范例 DateTime date1 = new DateTime(2008, 6, 1, 7, 47, 0); Console.WriteLine(date1.
ldt_date = today()
有什么建议吗?在.NET中,您可以使用 就像
yourdate.ToString("d")
范例
DateTime date1 = new DateTime(2008, 6, 1, 7, 47, 0);
Console.WriteLine(date1.ToString());
// Get date-only portion of date, without its time.
DateTime dateOnly = date1.Date;
// Display date using short date string.
Console.WriteLine(dateOnly.ToString("d"));
您可以添加ToString格式
yourdate.ToString("d");
这是正常的.NET行为
DateTime dt = DateTime.Today;
Console.WriteLine(dt.ToString); //output 6/23/2012 12:00:00 AM
如果您只想要日期(2012年6月23日),请尝试:
如果你得到了想要的信息,别忘了升级投票并将答案标记为已接受……你是说你已经转换为PowerBuilder.NET还是其他.NET语言了?
DateTime dt = DateTime.Today;
Console.WriteLine(dt.ToShortDateString()); //output 6/23/2012