Subject: How to print dates of month in DROP DOWN
Posted By: doosti Post Date: 9/29/2006 5:51:23 AM
 Dear All,

I want to print dates of the month in a drop down menu. Actually i am designing a page which will extract transactions between the supplied dates by the user. Is there any way i can print dates in a drop down menu? LIke FROM (date) TO (date)?

Farzan Q.
MS(TeleCommunication)
Mohammad Ali Jinnah University.
Reply By: tctekkie Reply Date: 9/29/2006 12:55:26 PM
If I understand correctly, the following code is an example of what I use.  I haven't tested it so it may need to be checked for spelling, etc.


<%
'Dimension your variables
Dim sSQL, rs, oConn
Dim sConnect

Dim sSelectFrom
Dim sSelectTo

'Define your connection string
sConnect = "<your connection string>"

'Create your connection object & open
SET oConn = Server.CreateObject("ADODB.Connection")
oConn.open sConnect

'Create your recordset object
Set rs = Server.CreateObject("ADODB.Recordset")


'define sql string
sSQL = "<your sql query>"

'open the recordset containing the dates of the transactions
rs.open sSQL, oConn

'Store your select list to a variable
sSelectFrom = "<select name=""TransFrom"" id=""TransFrom"">" & vbCrlf
sSelectTo = "<select name=""TransTo"" id=""TransTo"">" & vbCrlf

if NOT rs.EOF then 'test for empty recordset
  Do UNTIL rs.eof  'loop through your recordset
     sSelectFrom = sSelectFrom & "<option value=""" & rs("TransFrom") & """>" &_
                                  FormatDateTime(rs("TransFrom"),vbShortDate) & _
                                 "</option>" & vbCrlf
     sSelectTo = sSelectTo & "<option value=""" & rs("TransTo") & """>" &_
                                  FormatDateTime(rs("TransTo"),vbShortDate) & _
                                 "</option>" & vbCrlf
     rs.MoveNext
  Loop
End If

'Finish building your select lists
sSelectFrom = sSelectFrom & "</select>" & vbCrlf
sSelectTo = sSelectTo & "</select>" & vbCrlf


'Close & Destroy your Recordset & Connection Objects 
rs.close
set rs = nothing

oConn.close
set oConn = nothing
%>


then in your HTML Code simply response.write your variables.

Hope that helps!



  



Reply By: doosti Reply Date: 9/29/2006 11:36:00 PM
quote:
Originally posted by tctekkie

If I understand correctly, the following code is an example of what I use.  I haven't tested it so it may need to be checked for spelling, etc.


<%
'Dimension your variables
Dim sSQL, rs, oConn
Dim sConnect

Dim sSelectFrom
Dim sSelectTo

'Define your connection string
sConnect = "<your connection string>"

'Create your connection object & open
SET oConn = Server.CreateObject("ADODB.Connection")
oConn.open sConnect

'Create your recordset object
Set rs = Server.CreateObject("ADODB.Recordset")


'define sql string
sSQL = "<your sql query>"

'open the recordset containing the dates of the transactions
rs.open sSQL, oConn

'Store your select list to a variable
sSelectFrom = "<select name=""TransFrom"" id=""TransFrom"">" & vbCrlf
sSelectTo = "<select name=""TransTo"" id=""TransTo"">" & vbCrlf

if NOT rs.EOF then 'test for empty recordset
  Do UNTIL rs.eof  'loop through your recordset
     sSelectFrom = sSelectFrom & "<option value=""" & rs("TransFrom") & """>" &_
                                  FormatDateTime(rs("TransFrom"),vbShortDate) & _
                                 "</option>" & vbCrlf
     sSelectTo = sSelectTo & "<option value=""" & rs("TransTo") & """>" &_
                                  FormatDateTime(rs("TransTo"),vbShortDate) & _
                                 "</option>" & vbCrlf
     rs.MoveNext
  Loop
End If

'Finish building your select lists
sSelectFrom = sSelectFrom & "</select>" & vbCrlf
sSelectTo = sSelectTo & "</select>" & vbCrlf


'Close & Destroy your Recordset & Connection Objects 
rs.close
set rs = nothing

oConn.close
set oConn = nothing
%>


then in your HTML Code simply response.write your variables.

Hope that helps!



  







Thanks for the reply. It seems that i have to extract dates from the database and then show in he drop down menu. What i want to do is i want to generate dates automatically and have to show them in the drop down menu. And when the dates got selected then query should be run to extract the dates between the supplied dates..

If you can help me with this too?

Farzan Q.
MS(TeleCommunication)
Mohammad Ali Jinnah University.
Reply By: dparsons Reply Date: 10/2/2006 9:30:01 AM
Cross post: http://p2p.wrox.com/topic.asp?TOPIC_ID=50414

--Stole this from a moderator

I will only tell you how to do it, not do it for you.  
Unless, of course, you want to hire me to do work for you.

Go to topic 50414

Return to index page 159
Return to index page 158
Return to index page 157
Return to index page 156
Return to index page 155
Return to index page 154
Return to index page 153
Return to index page 152
Return to index page 151
Return to index page 150