Results 1 to 4 of 4

Thread: Date Calculation

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2002
    Posts
    113

    Date Calculation

    I have an SQL statement that returns the week number using the DatePart function. Is their a way I can get the friday date of the week number it returns to me ?

    Thanks in advance for any help !!

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Date Calculation

    well.. it isnt pretty.. but it works

    VB Code:
    1. Dim DTE As Date
    2. Dim tmp As Integer
    3. tmp = WEEK_NUM_FROM_SQL
    4. DTE = CDate("1/1/" & Year(Date)) 'set to the first day of this year
    5. Do Until Format(DTE, "ww") = tmp 'loop till it hits the week returned
    6.     DTE = DateAdd("d", 1, DTE)
    7. Loop
    8. Do Until Weekday(DTE) = vbFriday 'find the friday
    9.     DTE = DateAdd("d", 1, DTE)
    10. Loop
    11. MsgBox DTE
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Date Calculation

    Substitute the date for NOW. Weekday() returns an integer.

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.   MsgBox WeekdayName(Weekday(Now))
    5. End Sub

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Date Calculation

    dave, he needs to find the Friday of the week number returned...

    like currently its week # 39.. so he would need it to return 9/23/05

    (At least thats how I understood it)
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width