Dates again....urrgh!

Results 1 to 3 of 3

Thread: Dates again....urrgh!

  1. #1

    Default Dates again....urrgh!

    Hi guys,<BR>I have a question regarding dates. I have a web form that allows a user to select from 2 dropdowns. The first is the month, and the second is the day number 1 &#062; 31.<BR><BR>Heres how Im constructing it.<BR><BR>yearmonth = request.form("yearmonth")<BR>yearday = request.form("yearday")<BR><BR>edate = DateSerial(Year(StartDate), (yearmonth) + iOffset, yearday)<BR><BR>*StartDate is simply a previously selected commencement date*<BR><BR>The problem Im experiencing is that day 31 of a particular month may not exist, causing edate to simply roll to the next month. It does this successfully, however I need to identify this and flag a message to the user indicating that the day they have selected is not valid for that particular month.<BR><BR>Any thoughts?<BR><BR>Thanks in advance,<BR>John

  2. #2
    Join Date
    Dec 1969

    Default You need a steady girlfriend... you won&#039;t have to worry so much about getting dates.<BR><BR>Easy.<BR><BR>What&#039;s the bit with iOffset though????<BR><BR>&#060;%<BR>yearmonth = CINT(request.form("yearmonth"))<BR>yearday = CINT(request.form("yearday"))<BR><BR>edate = DateSerial(Year(StartDate), yearmonth, yearday)<BR><BR>If Month(edate) &#060;&#062; yearmonth OR Day(edate) &#060;&#062; yearday Then<BR> Response.Write "You chose an invalid month/day combination"<BR> ...<BR>End If<BR>%&#062;<BR><BR>Alternative:<BR><BR>&#060;%<B R>yearmonth = CINT(request.form("yearmonth"))<BR>yearday = CINT(request.form("yearday"))<BR><BR>maxday = Day( DateSerial(Year(StartDate), yearmonth+1, 0) )<BR><BR>If yearday &#062; maxday Then<BR> Response.Write "There are only " & maxday & " days in that month!"<BR> ...<BR>End If<BR>...<BR>%&#062;<BR><BR><BR><BR>

  3. #3

    Default Why Bill? I have you!

    Cheers, thanks for that. As usual you make it look so easy.<BR><BR>As for the iOffset...dunno. It was a bit of code that stuck on me. Seemed to work well though. But I guess If its unecessary well then I&#039;ll ditch it. I understand your code.<BR><BR>Thanks again Billy boy!<BR><BR>John

Posting Permissions

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