Display date and Desc as varchar field

Posted on 2012-08-16
Last Modified: 2012-08-16
I'm in SQL Server and I want to update a varchar field with today's year and a desc.  Ex:
2012 Training
I've tried DATEPART(yy, { fn NOW() }) & ' Training'
but I get the error...
Conversion failed when converting the varchar value ' Training' to data type int.
How do I do this?
Question by:BobRosas
    LVL 65

    Accepted Solution

    SELECT CAST(YEAR(GETDATE()) as char(4)) + ' Training'

    Author Comment

    Thank you for your quick response!  It worked like a charm!

    Author Closing Comment

    LVL 65

    Expert Comment

    by:Jim Horn
    Couple of things SQL-specific:
    (1)  YEAR returns an integer, so to concatenate it with a string you have to CAST it as a string.
          So does DATEPART, which is why you received the error.
    (2)  SQL uses plus marks ( + ) for string concatenation.
    (3)  Did you want two-digit years (yy) or four (2012)?

    Author Comment

    The four digit year was just what I needed.
    Thank you so much for the explanation as well.  I really appreciate it.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
    SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now