A Quick question.

  • Being newish to SQL Server I hope someone can help.

    In a table I store dates as integers.  I access this table from a view, when I list the date fields they are integers, is there anyway in the view that you can convert the Date fields as dates??

  • In your view change the select for the column you want changed to

    cast( <column> as datetime)



    Shamless self promotion - read my blog http://sirsql.net

  • Sure, just create the VIEW with an expression for you date column data. However, you will not be able to UPDATE the "date" data using this VIEW. (Maybe see TRIGGERs - INSTEAD OF, in BOL, for updating values through the VIEW itself.)



    Once you understand the BITs, all the pieces come together

  • Post examples of how your dates currently look. That will help us come up with a way to convert them to DATETIME.

    -SQLBill

  • Using the cast command within the view worked.

     

    Thanks for all your help.

     

    Kevin

Viewing 5 posts - 1 through 4 (of 4 total)

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