Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 4
    time has a scale. Try time(0). On a different note, why are you storing dates as a varchar and not a datetime or datetime2? Also, TRY_PARSE and time were introduced in SQL Server 2012, however, you've tagged SQL Server 2008 and 2005? Commented Nov 11, 2018 at 22:47
  • Before you go any further you should take some time to understand data types. Also it's important to understand that this kind of formatting is usually best achieved in the 'presentation layer'. If this is for a report or an application then format it in there, not in the database. Commented Nov 11, 2018 at 22:59
  • 1
    Possible duplicate of SQL Server remove milliseconds from datetime Commented Nov 11, 2018 at 23:43
  • You can cast the column to a time as follows.I am assuming that the column "data" is a date datatype. If yes then, select cast(data as time) from table_1 Commented Nov 12, 2018 at 1:34