0

I want to convert the date format from 06/10/2014 5:33:32 PM to 2014-10-06 17:28:44.000 format

guide me Please ...

QUERY

select CONVERT(VARCHAR(22),'06/10/2014 5:33:32 PM', 120)

RESULT

06/10/2014 5:33:32 PM

Ullas
  • 11,450
  • 4
  • 33
  • 50
jaba2412
  • 39
  • 4
  • possible duplicate of [Convert date format yyyy-mm-dd => dd-mm-yyyy](http://stackoverflow.com/questions/2487921/convert-date-format-yyyy-mm-dd-dd-mm-yyyy) – Shmwel Jun 12 '14 at 05:43
  • Try to convert unix time and reformat as you need. http://stackoverflow.com/questions/2904256/how-can-i-convert-bigint-unix-timestamp-to-datetime-in-sql-server Maybe help you. – oneassasin Jun 12 '14 at 05:43
  • You should try to avoid doing any string manipulation of values that ought to be `date`s down in the database, if possible - keep them in `datetime2` columns/variables and let client libraries translate those into the appropriate data types in the client programs accessing the database, and only actually convert into a string when presenting it to the user. – Damien_The_Unbeliever Jun 12 '14 at 05:56

1 Answers1

0

The below sql query will work :

select CONVERT(datetime,'06/10/2014 5:33:32 PM', 101)

As per @Damien_The_Unbeliever comments, If OP treats 06 as day and 10 as month

select CONVERT(datetime,'06/10/2014 5:33:32 PM', 103)

Please follow the link for SQL Date formats

Prahalad Gaggar
  • 11,389
  • 16
  • 53
  • 71
  • Since the OP's desired output is `2014-10-06 17:28:44.000`, and only SQL Server in insane mode believes that anyone would think that such a date was `yyyy-dd-mm`, I think the `06` is meant to be the day and `10` the month. Therefore `101` is probably wrong and `103` might be more appropriate. – Damien_The_Unbeliever Jun 12 '14 at 06:12