Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 29th, 2006, 05:51 AM
Authorized User
 
Join Date: Nov 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to print dates of month in DROP DOWN

 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.
__________________
Farzan Q.
MS(TeleCommunication)
Mohammad Ali Jinnah University.
 
Old September 29th, 2006, 12:55 PM
Registered User
 
Join Date: Sep 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Code:
<%
'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! :D







 
Old September 29th, 2006, 11:36 PM
Authorized User
 
Join Date: Nov 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
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.

Code:
<%
'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! :D







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.
 
Old October 2nd, 2006, 09:30 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

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.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting month name to month number kalyanykk SQL Server 2005 7 August 19th, 2008 10:37 PM
How to print dates of month in DROP DOWN doosti Classic ASP Basics 5 October 2nd, 2006 09:32 AM
query Current Month, Month+1, Month+2, Month+3 anterior Access 2 September 24th, 2006 08:25 PM
Dates Skips Over Month harpua Pro PHP 0 January 31st, 2006 02:10 PM
ASP - Drop Down Box with Dates HelpMe Classic ASP Databases 1 October 21st, 2004 10:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.