Convert numeric field (date field) into date field

  • I am using SQL Server 2008 I want to create a view. I have a field call inv_date and is numeric, a date field yymmdd what I want to do is convert it into mm/dd/yyyy and call the field Invoice_Date. I try to google in how to convert, but everything is for yyyymmdd format not yymmdd. All I want to do is to type in my view a date for example: Between 1/1/2016 and 6/24/2016. Any tip will be appreciated. Thank you in advance.

  • Something like this?

    SELECT CONVERT(date,CONVERT(char(6),'160627'),12)

    Avoid storing dates as numbers or strings. Use date/time data types which will allow better performance and capabilities.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Thanks

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

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