Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Posts
    2

    Unhappy Unanswered: I Want to Calculate the date next friday

    I have a database in access wherein i have to enter requests every day.
    these generate weekly reports wherein i have to mention a field week-ending (which ends every friday) so a new week starts on saturday.
    lets say i have a request coming in on 21st oct 2003, i enter the date recieved as 21-oct-03, my week ending should automatically become 24th october 2003 (the very next friday after the request) in my form.
    pls. help.

  2. #2
    Join Date
    Oct 2003
    Posts
    706

    Re: I Want to Calculate the date next friday

    [i]
    lets say i have a request coming in on 21st oct 2003, i enter the date recieved as 21-oct-03, my week ending should automatically become 24th october 2003 (the very next friday after the request) in my form.
    pls. help.

    There's a wide variety of functions in Access for date manipulation. So what you do is extract the day-of-the-week and from this, say with a Select Case statement, calculate the number of days until Friday. Then use "DateAdd" to add that number of days to the date.
    ChimneySweep(R): fast, automatic
    table repair at a click of the
    mouse! http://www.sundialservices.com

  3. #3
    Join Date
    Oct 2003
    Posts
    2
    im not too comfortable with VB code,
    i can manipulate code using JAVA...
    i assume its similar in VB.. but how?
    i wrote a function..

    If VBADate.WeekDay=Sunday then
    Value=VBADate.Date+5.....
    if VBADate.WeekDay=Monday then
    Value=VBADate.Date+4.....
    and so on..
    end if

    how to manipulate/call this function??
    thanks for the response..

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Try something like that

    dim GivenDayOfWeek as byte
    dim daytTillWeekEnd as byte
    dim RequiredDate as date

    GivenDayOfWeek= Weekday(yourDate)

    select case GivenDayOfWeek
    case 1 ' Sunday
    daytTillWeekEnd=5

    case 2 ' Monday
    daytTillWeekEnd=4

    ...
    ...


    case 6 'Friday
    daytTillWeekEnd=0



    case 7 'Saturday
    daytTillWeekEnd=6

    end select

    RequiredDate = ("d", daytTillWeekEnd, yourDate)



Posting Permissions

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