【发布时间】:2011-11-14 14:21:43
【问题描述】:
如何在 Visual Basic 中将日期格式化为 sql 121 样式(即 yyyy-mm-dd hh:mi:ss.mmm)。
我意识到这种格式不在 FormatDateTime 对象列表中。
我想将此格式用于 Reporting Services。
【问题讨论】:
标签: sql sql-server vb.net sql-server-ce
如何在 Visual Basic 中将日期格式化为 sql 121 样式(即 yyyy-mm-dd hh:mi:ss.mmm)。
我意识到这种格式不在 FormatDateTime 对象列表中。
我想将此格式用于 Reporting Services。
【问题讨论】:
标签: sql sql-server vb.net sql-server-ce
date.ToString("yyyy-MM-dd HH:mm:ss.fff")
【讨论】:
因为这对我有帮助,我想我会补充一点。 如果作为字符串传递给方法,则:
Shared SomeFunction(ByRef sStartDate as String)
Dim StartTime As DateTime = DateTime.Parse(sStartDate)
command.Connection = connection
command.CommandType = CommandType.StoredProcedure
command.CommandText = "SomeStoredProcedure"
command.Parameters.Add("@StartDateTime", SqlDbType.DateTime)
command.Parameters("@StartDateTime").Value = StartTime.ToString("yyyy-MM-dd HH:mm:ss.fff")
干杯!
【讨论】: