Reputation: 1668
How can I format a date in Visual Basic to be in sql 121 style (that is yyyy-mm-dd hh:mi:ss.mmm).
I realized that this format is not in the FormatDateTime list of objects.
I want to use this format for Reporting Services.
Upvotes: 1
Views: 14583
Reputation: 13
Since this helped me, I thought I would add a bit. If passed into a method as a string then:
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")
Cheers!
Upvotes: 0
Reputation: 13422
date.ToString("yyyy-MM-dd HH:mm:ss.fff")
Custom Date and Time Format Strings
Upvotes: 11