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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with displaying May/2003 in dropbox if database field = 05/12...

Status
Not open for further replies.

TonyU

Technical User
Feb 14, 2001
1,317
US
[tt]
Hello all, I need help figuring out how to display Month(s) and Year on a drop-down box if my SQL date field = 05/12/2003

Here's where I am so far,


Here's my populated drop-down box
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<select name=&quot;date&quot;>
<option value=&quot;*****&quot;>Search Date</option>
<%
While (NOT rsDropDown.EOF)
%>
<option value=&quot;<%=(rsDropDown.Fields.Item(&quot;date&quot;).Value)%>&quot; ><%=(rsDropDown.Fields.Item(&quot;date&quot;).Value)%></option>
<%
rsDropDown.MoveNext()
Wend
If (rsDropDown.CursorType > 0) Then
rsDropDown.MoveFirst
Else
rsDropDown.Requery
End If
%>
</select>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here's my populated drop-down box



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here's my drop-down box RECORDSET

<%
Dim rsDisplayDate__MMColParam
rsDisplayDate__MMColParam = &quot;0-0-000&quot;
if (Request(&quot;date&quot;) <> &quot;&quot;) then rsDisplayDate__MMColParam = Request(&quot;date&quot;)
%>
<%
set rsDisplayDate = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsDisplayDate.ActiveConnection = MM_dsn_STRING
rsDisplayDate.Source = &quot;SELECT * FROM SQL_VW WHERE date = '&quot; + Replace(rsDisplayDate__MMColParam, &quot;'&quot;, &quot;''&quot;) + &quot;'&quot;
rsDisplayDate.CursorType = 0
rsDisplayDate.CursorLocation = 2
rsDisplayDate.LockType = 3
rsDisplayDate.Open()
rsDisplayDate_numRows = 0
%>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here's my drop-down box RECORDSET



The question is:
How can I populate the drop-down box to display
May or May/2003, query the database and display everything from 05/2003 ?

Keep in mind that my database contains 05/12/03







-Tony
Delete * from brain Where MaxLevel = &quot;Full&quot; and reaction = &quot;Slow&quot; order by StartOver
 
Look at the SQL datepart function. Also look at the VBscript DatePart and MonthName functions.

For your SQL you will probably do something like
WHERE datepart(mm,date) = datepart(mm,&quot; & rsDisplayDate & &quot;) AND datepart(yy,date) = datepart(yy,&quot; & rsDisplayDate & &quot;).

For the ASP you can display like this:
MonthName(DatePart(&quot;m&quot;,yourdatevalue)) & &quot; &quot; & DatePart(&quot;yyyy&quot;,yourdatevalue)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top