date problem

Results 1 to 6 of 6

Thread: date problem

  1. #1
    DKL Guest

    Default date problem

    Hi,<BR><BR>I have a text field in asp screen which accepts date in the format 01W20 which represents 20th week in 2001. I need to get the last date in the 20th week in 2001. I really appreciate some guidance to implement this logic.<BR><BR>Thanks

  2. #2
    Krank could do Guest

    Default RE: date problem

    dim myDate, strDate<BR><BR>strDate = Request.Form(txtBoxName")<BR><BR>myDate = dateAdd("ww", cint(right(strDate,2),cdate("01/01/" & left(strDate,2)))<BR><BR>&#039;now mydate should be the 20 weeks after 1/1/2001<BR><BR>now do <BR><BR>myDate=dateAdd("d", 7-Weekday(myDate, 1),myDate) to get the lsat date in that week<BR><BR>

  3. #3
    DKL Guest

    Default Thanks a lot

    I will try it

  4. #4
    LeeAnnie Guest

    Default RE: date problem

    A. I think the first hurtle is to decide what constitutes a week? ...and what week in any given year is the first week? (Would it be the first week with at least 4 days in it, the first full week, or the week that includes Jan 1, even if Jan 1 is a Saturday?)<BR><BR>B. The next thing you will need to decide is what day of the week is the last day? (Friday, if we are talking "business week" or Saturday if we are talking about "calendar weeks")<BR><BR>Once you have the above pieces of info, I would then add 140 (20x7) days to the week you came up with in A, and then get last day of that week, based on B.<BR><BR><BR>Here is the full specification for the DatePart() function that will help you further. <BR><BR><BR>I hope this got you a little closer.<BR><BR>

  5. #5
    LeeAnnie Guest

    Default Yep! That should do it!

    Good job, Krank!<BR><BR>DKL - just make sure that you are addressing any business rules that you may need to consider.... I have those listed in my previous response!<BR><BR>

  6. #6
    Join Date
    Dec 1969

    Default Good point on the

    business week issue, I forgot abou that, he&#039;ll have to do a max of 5-dayofweex and 0 to ensure he doesn&#039;t get any negative days added.

Posting Permissions

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