date time

  • I have a table that I am using to track a users progress on a set of forms. The rows are datetime format. I would like to test if a field is null, and if it is display a 0 otherwise a 1. I tried ISNULL(step1, 0) AS Step1 but it returns 1/1/1900 instead of a 0. Is there a way to test this so I can get a 0 for null? If there is no date in the field then the user has not started that step yet.

  • Something like this?

    declare @dt datetime

    select case when @dt is null then 0 else 1 end

    set @dt=getdate()

    select case when @dt is null then 0 else 1 end

               

    -----------

    0

    (1 row(s) affected)

               

    -----------

    1

    (1 row(s) affected)

     

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

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

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