Home Forums SQL Server 2008 T-SQL (SS2K8) Problem with CAST to VARCHAR with SUBSTRING Function RE: Problem with CAST to VARCHAR with SUBSTRING Function

  • The following works :

    SELECT

    CASE WHEN LEFT(Customer.StartDate, 2) = '98' THEN substring(convert(varchar(20),Customer.StartDate), 3, 2)

    WHEN LEFT(Customer.StartDate, 2) = '99' THEN substring(convert(varchar(20),Customer.StartDate), 3, 2)

    END AS LossMo

    FROM Customer

    The StartDate column is numeric (7,2).

    Thanks.

    For better, quicker answers on T-SQL questions, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/