Convert nvarchar to datetime in select is big problem.

  • Hello,

    I have this select>

    select * from table where  col between 1.7.2004  and 31.7.2004

    col is nvarchar and data in this column is in format dd.mm.yyyy

    I would like select records from 1.7.2004 (dd.mm.yyyy) to 31.7.2004(dd.mm.yyyy), when col is nvarchar.

    thanks zdenek

  • How 'bout

    WHERE CAST(col AS DATETIME) BETWEEN CAST('1.7.2004' AS DATETIME) AND CAST('31.7.2004' AS DATETIME)

    Granted the execution plan may look awful but this should work..



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply