Data type validations

  • I cannot use parse..

    Using Sql 2008..

    Thanks though it was really great info...

  • Note that ISDATE() has tons of odd interpretations as well.

    For example, '2013' returns as a valid date:

    SELECT ISDATE('2013')

    Which makes sense if you consider this returns 2013-01-01:

    SELECT CAST('2013' AS DATE)

    However, do you think of '2013' by itself as a valid date?

    Meanwhile, TRY_PARSE says '2013' is not a valid date:

    SELECT TRY_PARSE('2013' AS DATE)

    but of course 2013-01-01 is deemed valid:

    SELECT TRY_PARSE('2013-01-01' AS DATE)

    So, choose your validation techniques wisely and do not assume the name of a function matches the behavior that might be implied by your interpretation of that name.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

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

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