Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2012
    Posts
    5

    Unanswered: Datetime to text

    I need to produce 2 different results depending on whether a datetime field is completed or not. If I was doing this on a spreadsheet I would use -

    IF(CLOSED_DT<>0,"Yes","No")

    but I don't know how to duplicate this in SQL.

    Thanks.

    Francis

  2. #2
    Join Date
    Apr 2012
    Posts
    213
    Check out the page below:
    CASE (Transact-SQL)

    Hope this helps.

  3. #3
    Join Date
    Jun 2012
    Posts
    5
    Hi

    That worked perfectly -

    SELECT CASE WHEN CLOSED_DT <>0 THEN 'Yes' ELSE 'No'

    END

    Many thanks.

    Francis

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    can closed_dt be NULL? if yes, then testing for zero isn't enough

    by the way, do you really store 0 for some dates?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Jun 2012
    Posts
    5
    I'm constructing the basic SQL in Microsoft SQL Server Management Studio 2008, which did have NULL values and then copied it over to SQL Server Business Intelligence Development Studio as a separate dataset to enable a parameter. This produces a blank cell when there is no date.

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •