locked
Need help with SQL Query RRS feed

  • Question

  • Need some help with this query..

    This is what I have so far..

    Report the artist name and the age in years of the responsible member for each artist at the time of that artist's entry date.

    SELECT ArtistName, FORMAT((DateDiff(CurDate(),birthday)/365), 0)  As 'Age In Years', RespParty
    FROM XrefArtistsMembers

    Thursday, May 17, 2012 6:55 AM

Answers

  • SELECT ArtistName, DateDiff(year,birthday,getdate())  As 'Age In Years', RespParty
    FROM XrefArtistsMembers

    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/

    • Proposed as answer by Satheesh Variath Thursday, May 17, 2012 7:47 AM
    • Marked as answer by Kalman Toth Wednesday, May 23, 2012 5:36 AM
    Thursday, May 17, 2012 7:02 AM
    Answerer

All replies

  • SELECT ArtistName, DateDiff(year,birthday,getdate())  As 'Age In Years', RespParty
    FROM XrefArtistsMembers

    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/

    • Proposed as answer by Satheesh Variath Thursday, May 17, 2012 7:47 AM
    • Marked as answer by Kalman Toth Wednesday, May 23, 2012 5:36 AM
    Thursday, May 17, 2012 7:02 AM
    Answerer
  • Hi

    Try this

    SELECT ArtistName, DateDiff(YEAR,birthday,getdate())  As 'Age In Years', RespParty
    FROM XrefArtistsMembers
    

    Regards
    Satheesh

    Thursday, May 17, 2012 7:03 AM
  • try this

    SELECT ArtistName, DATEDIFF(YY,birthday,GETDATE()) As 'Age In Years', RespParty
    FROM XrefArtistsMembers

    thanks and Regards,

    Sandhya


    Sandhya

    Thursday, May 17, 2012 7:04 AM
  • SELECT ArtistName,  DATEDIFF(yy,@BIRTHDAY,GETDATE())  As 'Age In Years', RespParty
    FROM XrefArtistsMembers

    K A R T H I

    Thursday, May 17, 2012 7:33 AM