【问题标题】:VB and SQL datetimeVB 和 SQL 日期时间
【发布时间】: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


    【解决方案1】:
    date.ToString("yyyy-MM-dd HH:mm:ss.fff")
    

    Custom Date and Time Format Strings

    【讨论】:

      【解决方案2】:

      因为这对我有帮助,我想我会补充一点。 如果作为字符串传递给方法,则:

      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")
      

      干杯!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-05-15
        • 1970-01-01
        相关资源
        最近更新 更多