How to update the Year in a date field?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dvrameshusa
    New Member
    • Feb 2008
    • 2

    How to update the Year in a date field?

    Hi All,
    The AP clerks forgot to change the year from 2009 to 2010, so they did lots of data entry with invoice dates instead of 2010, they added 2009 and the date field looks like this "2009-01-16 00:00:00.000", is there a way to replace 2009 with 2010.

    Please help me and thanks in advance,
    Ramesh
    [email deleted]
    Last edited by RedSon; Mar 9 '10, 08:33 PM. Reason: Removing email
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    Don't post your email again.

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #3
      Try to do this if this is what you need:

      Code:
      select invoice_date, cast('2010' + right(convert(varchar(8), invoice_date,112),4)  as datetime) as new_invoice_date
      from YOURTABLE
      where year(invoice_date) = 2009
      Make sure that this is what you want before updating your table.

      Happy Coding!!!

      ~~ CK

      Comment

      Working...