score:6
The managed type that corresponds to the SQL time
data type is TimeSpan
(or TimeSpan?
when nullable), not DateTime
– refer to Mapping CLR Parameter Data for the list of type conversions.
You can use TimeSpan.Parse(myString)
to convert your string.
Read More
- Convert string to time clarification
- replace multiple values at the same time - in order to convert a string to a number
- How do I convert a Joda Time DateTime object into a String in SQL Server format?
- SQL function to convert a string into a time
- convert string to both date and time
- T-SQL concatenate & convert string to date time
score:-1
Instead of Convert.ToDateTime
use DateTime.TryParseExact(yourTimeString, "HH:mm",<other parameters>, out dateTime);
Other parameters are missing. Please look into the DateTime.TryParseExact
documentation. But basically it converts your string to dateTime from the format you are specified.
score:0
score:0
You can also use it like this
Convert.ToDateTime(myString).TimeOfDay();
This will return the time . And you can pass this value to Sql command parameter.
TimeOfDay
returns TimeSpan
object.
TimeSpan tp = Convert.ToDateTime(myString).TimeOfDay();
More questions
- Convert SQL Date time format to String
- How to convert SQL server 24 hour time string to 12 hour datetime data type
- Convert date time string in dd/mm/yyyy to datetime format mm/dd/yyyy
- SQL Server : convert string to numeric - Conversion failed when converting date and/or time from character string
- Convert Military time to string representation
- convert time in string to number of hours
- Conversion failed when converting date and/or time from character string while inserting datetime
- How to convert a datetime to string in T-SQL
- TSQL: How to convert local time to UTC? (SQL Server 2008)
- Convert Time DataType into AM PM Format:
- Convert SQL Server result set into string
- SQL Server convert string to datetime
- Convert NULL to empty string - Conversion failed when converting from a character string to uniqueidentifier
- SQL Server convert select a column and convert it to a string
- SQL Server Convert integer to binary string
- SQL convert time to milliseconds
- How do I convert SQL getdate() function into a string in dd/mm/yyyy format?
- MS SQL server - convert HEX string to integer
- convert string to date in sql server
- How to convert datetime to date only (with time set to 00:00:00.000)
- Convert a string with 'YYYYMMDDHHMMSS' format to datetime
- Convert mssql datetime object to PHP string
- Convert Historical Local Time to UTC Time in SQL Server
- Convert string into xml and insert Sql Server
More questions with similar tag
- Searching a range when using like %
- How to implement SQL Server paging using C# and entity framework?
- How to randomize order of data in 3 columns
- Query porformance vs performance of the same query in cursor
- SQL add processed ids to a single cell seperated with a comma
- SQL Server: how to get a database name as a parameter in a stored procedure
- SQL - Adding a blank row
- What are the dangers of dynamic SQL, and can they be avoided?
- Efficiently execute 100K update statements - C# & Sql Server
- Are all statements in a stored procedure ONE transaction
- Database column data type
- Weird performance of queries using 'max'
- How to reference a sql server with a backslash (\) in its name?
- T-SQL date conversion
- T-SQL Update based on subquery
- how to maintain table log (every changes) history in MS SQL by write trigger
- WHERE Something IN (CASE WHEN statement)?
- Why does Microsoft SSMS syntax highlight the word "configuration"?
- Find any of days is fall under list of dates
- Converting Text to varchar(MAX)
- Find the exact error record
- Cannot connect to SQL Server 2014 via java
- OpenRowSet - SQL Server
- Pentaho vs Microsoft BI Stack
- how to turn off autonumber in sql?
- Moving Complex Query Results to a Table
- SQL query runs 10 times slower with certain value when using variable
- SQL Server query combining UNION and NOT EXISTS
- one-to-many query selecting all parents and single top child for each parent
- Recursive SQL query (parent-child) to include total downline records per record