SQL set null values to 0

Posted on 2011-05-04
Last Modified: 2012-05-11

I have a query that calculates the total number of overtime hours a person worked for daily.  If the person did not work overtime, I get a result of "NULL".  How can I change this value to "0"?

Here is the part of the query that gives me the total hours worked per day:

TotalHours = Cast(substring( convert(varchar(10), dateadd(second,  sum(datediff(second, ClockIn, ClockOut)), 0),
108) , 1,2) + '.' + Cast((Cast(substring(convert (varchar(10), dateadd(second, sum(datediff(second, ClockIn, ClockOut)),
 0), 108) ,4,2) as Int) * 10)/6 as varchar(4)) as decimal(4,2)),
Question by:NerishaB
    LVL 10

    Accepted Solution

    Try isnull(column, 0)

    Author Closing Comment

    cool, thanks

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
    This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
    Via a live example, show how to shrink a transaction log file down to a reasonable size.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now