Calculate Weekending date.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David

    Calculate Weekending date.

    Can someone help me with this. I need to calculate the week ending
    date of the first week of the year based upon a year provided by the
    user. Is there a simpler way other than writing my own UDF?
  • James Goodwin

    #2
    Re: Calculate Weekending date.


    "David" <david.paskiet@ t-mobile.com> wrote in message
    news:9abbaed9.0 411160734.1d9c0 21f@posting.goo gle.com...[color=blue]
    > Can someone help me with this. I need to calculate the week ending
    > date of the first week of the year based upon a year provided by the
    > user. Is there a simpler way other than writing my own UDF?[/color]

    That depends on what week ending date and first week of the year mean.

    If 1 Jan is on Wednesday do you want to come back with 4 Jan, 5 Jan, 11 Jan
    or 12 Jan?

    Anyway, Generally, the last day of a week is Date +7 - Day(Date) where Day()
    returns the number of the day in the week (1=Sun, 2=Mon, 3=Tue,
    etc...Assuming the week starts on Sunday)

    Therefore DateAdd(d,-DatePart(dw,dat efield),DateAdd (d,7,datefield) )

    However, if the datefield contains a time you may want to change the time if
    you are using this in a comparison.

    Regards,
    Jim


    Comment

    Working...