Cast as

  • Hi,

    I am using a case statement to check for row numbers.

    But I want to change the format of a date and number fields.

    1.

    Current: June 29 2011 12:00 AM

    Expected: dd/mm/yyyy(no seconds)

    Code: CASE WHEN RowId = 1 THEN CAST(IssueDate AS VARCHAR(20))

    ELSE ''

    2.

    Current: 145671.39

    --------------0

    Expected:145671.39

    ---------null\blank

    using float but it is adding a zero to the next row? it should be null.

    Code: CASE WHEN RowId = 1 THEN CAST(InvoiceTotal AS FLOAT)

    ELSE ''

    Thanks for helping

  • ringovski (7/17/2011)


    1.

    Current: June 29 2011 12:00 AM

    Expected: dd/mm/yyyy(no seconds)

    Code: CASE WHEN RowId = 1 THEN CAST(IssueDate AS VARCHAR(20))

    ELSE ''

    SELECT CONVERT(VARCHAR(20), GETDATE(), 103)

    18/07/2011

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

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