Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Help

Status
Not open for further replies.

anon47

Programmer
Nov 28, 2006
80
US
I have the code below it allows me to choose a date from today to 30 days from now but excludes any days past the 28th of the month. Now it works great but if I choose today’s date it gives a null value and the database returns a mismatch data error. if I choose tomorrow or any date pass today it works great. Any help with this?


<%
'0-29 = 30
'1-30 = 30
For x = 0 to 29
NewDate = DateAdd("d", x, Date())
If Day(NewDate) < 29 Then
Response.write "<option value=""" & NewDate & """>" & NewDate & "</option>" & vbCrLf
End If
Next
%>
 
As far as I can tell, your code above does what you want it to. If there is an error, it is likely in the code that builds your SQL statement. Could you post that as well?

Also, is there a reason your omitting the 29th, 30th, and 31st of the month? It shouldn't be necessary unless you have a secondary requirement for it, as DateAdd will properly rollover to the next month.

-T

 
Ok the code below works like this. You choose a date from a drop down menu that is located on a form. When you click the submit button it takes you to a processing page where your information is then transmitted to a database located on the server. What happens is that if you choose the firstdate in the drop down menu and try to submit the information as a "strDate=Trim(Request.Form("date"))" it gives a "Provider error '80020005' Type mismatch." but if I choose the second or beyond date from the list it works.


<SELECT size=1 name=date tabindex="14">
<OPTION value="" selected></OPTION>
<OPTION value=
<%
'0-29 = 30
'1-30 = 30
For x = 0 to 29
NewDate = DateAdd("d", x, Date())
If Day(NewDate) < 29 Then
Response.write "<option value=""" & NewDate & """>" & NewDate & "</option>" & vbCrLf
End If
Next
%>
</OPTION>
</SELECT>
 
got it I had one option on top of another.
correct code below.


<SELECT size=1 name="date" tabindex="14">
<OPTION value="" selected></OPTION>
<%
'0-29 = 30
'1-30 = 30
For x = 0 to 29
NewDate = DateAdd("d", x, Date())
If Day(NewDate) < 29 Then
Response.write "<option value=""" & NewDate & """>" & NewDate & "</option>" & vbCrLf
End If
Next
%>
</SELECT>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top