• Nordest,

    There is no direct function and it depends on what you want...

    If you wish to use a SELECT to return all records for the year of the current date to the current date, this automatically works every time...

    SELECT yada-yada

      FROM yourtable

     WHERE somedatefield >= DATEADD(yy,DATEDIFF(yy,0,GETDATE()),0)

    If you wish to find the number of days in for YTD, this will work nicely...

    SELECT DATEPART(dy,GETDATE())

    Your request was a bit vague as to which type of YTD function you wanted.  If you want a SUM or a COUNT of something, post back.  It would be good include table schema and some sample data in the form of insert statements for the quickest help.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)