Results 1 to 3 of 3

Thread: Give me the Date from the Week

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Talking Give me the Date from the Week

    Is there a way to give me Sunday's date on the 11th week of this year in this formatt?

    dd/mm/yyyy

    thanks

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Code:
    Function StartDateOfWeek(iWeekNo As Integer, iYearNo As Integer) As Date
        Dim d As Date
        d = "01.01." & iYearNo
        StartDateOfWeek = d + ((iWeekNo - 1) * 7)
    End Function
    
    Function NextDay(ByVal d As Date, ByVal DayCode As Long) As Date
        NextDay = d - Weekday(d) + DayCode + IIf(Weekday(d) < DayCode, 0, 7)
    End Function
    use them like this:

    Code:
    MsgBox Format(NextDay(StartDateOfWeek(11, Year(Date)), vbThursday), "dd/mm/yyyy")
    peet

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216
    This works really well!

    Code:
    Function CJulian2Date (JulDay As Integer, Optional YYYY)
          If IsMissing(YYYY) Then YYYY = Year(Date)
          If Not IsNumeric(YYYY) Or YYYY \ 1 <> YYYY Or YYYY < 100 Or YYYY _
            > 9999 Then Exit Function
          If JulDay > 0 And JulDay < 366 Or JulDay = 366 And _
          YYYY Mod 4 = 0 And YYYY Mod 100 <> 0 Or YYYY Mod 400 = 0 Then _
                 CJulian2Date = DateSerial(YYYY, 1, JulDay)
        End Function 
    
    To test this function, type the following line in the Debug window and then press ENTER: 
    
    ?CJulian2Date(32, 1996)

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