Tuesday, December 30, 2014

QUery help

>substring(cast('410201' as varchar),1,6)


That is not a valid date string literal.


The following is valid (YYYYMMDD format):



select convert(date,substring(cast('20410201' as varchar),1,8)) as date
-- 2041-02-01

You can just prefix the data with '20' to make it into a valid date literal.







Kalman Toth Database & OLAP Architect SQL Server 2014 Database Design

New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014











No comments:

Post a Comment