Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How to convert Date in varchar(50) format MM/DD/YYYY HH:MM into YYYY-MM-DD format using MS SQLServer 2008 R2 ?

$
0
0

Hi,

I am getting the error "The conversion of a varchar data type to a datetime data type resulted in an out-of-range value."


when converting date in format Date in varchar(50) format MM/DD/YYYY HH:MM into YYYY-MM-DD format using MS SQLServer 2008 R2.


Please note that the date in column is Date(varchar(50), null).

I used the following syntax:

SELECT  CONVERT(VARCHAR(10), Date, 102) AS Day


FROM   dbo.[RCap_2G MM/Operator]


WHERE  (CONVERT(VARCHAR(10), Date, 102) > { fn NOW() } - 1)


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>