当我在 Windows Server 2008 R2 上工作时,我的应用程序的行为有所不同。
当我将我的 PowerScript 转换为 .net 项目时, today() 的函数将值作为日期以及时间(日期+时间)返回,而不仅仅是日期。
ldt_date = today()
有什么建议么?
当我在 Windows Server 2008 R2 上工作时,我的应用程序的行为有所不同。
当我将我的 PowerScript 转换为 .net 项目时, today() 的函数将值作为日期以及时间(日期+时间)返回,而不仅仅是日期。
ldt_date = today()
有什么建议么?
您可以添加 ToString 格式
yourdate.ToString("d");
这是正常的 .NET 行为。
DateTime dt = DateTime.Today;
Console.WriteLine(dt.ToString); //output 6/23/2012 12:00:00 AM
如果您只想要日期(2012 年 6 月 23 日),请尝试:
DateTime dt = DateTime.Today;
Console.WriteLine(dt.ToShortDateString()); //output 6/23/2012
在 .NET 中,您可以使用DateTime.Date 属性获取 DateTime 变量的唯一日期部分
就像是
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"));