Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Old 01-29-2007, 12:04 PM Help with Years...
Junior Talker

Posts: 3
Trades: 0
Hi there...I am creating a drop-down with years. Now I need to display 10 years starting from this year so 2007, 2008, 2009...2017. So next year the drop down will show 2008, 2009,....2018...I think year(Date+1) is pretty stupid to try...but I did and offcourse it doesnt work)

<select name=ExpirationYear class=fields>

<option></option>
<option value="Sign In"><%=Year(Date) %></option>
<option value="Sign In From Unpaid break"><%=Year(Date+1) %></option>
<option value="Sign Out For Unpaid break">2009</option>
<option value="Sign Out">2010</option>
<option value="Sign In">2011</option>
<option value="Sign In From Unpaid break">2012</option>
<option value="Sign Out For Unpaid break">2013</option>
<option value="Sign Out">2014</option>
<option value="Sign In">2015</option>
<option value="Sign In From Unpaid break">2016</option>
<option value="Sign Out For Unpaid break">2017</option>
<option value="Sign Out">2018</option>

</select>

Any clues???
terp_in_umcp is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-29-2007, 12:17 PM Oops...I got it:)
Junior Talker

Posts: 3
Trades: 0
Hey there...sorry for posting too soon...looks like i got the answer...silly me...its <%=Year(Date)+2%>
terp_in_umcp is offline
Reply With Quote
View Public Profile
 
Old 01-30-2007, 05:46 AM Re: Help with Years...
bbutton's Avatar
Experienced Talker

Posts: 43
Name: Bill Button
Location: Reading,UK
Trades: 0
Hi,

You can also use the DateAdd function, I know you have already solved the problem. But its a function worth nowing.

http://www.w3schools.com/vbscript/func_dateadd.asp
__________________
Bill Button

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
bbutton is offline
Reply With Quote
View Public Profile Visit bbutton's homepage!
 
Old 02-05-2007, 04:06 AM Re: Help with Years...
saadatshah's Avatar
Extreme Talker

Posts: 215
Name: Syed Saadat Ali
Location: Lahore, Pakistan
Trades: 0
My suggestion is write a function which can accept two parameters StartYear & EndYear and generate a dropdown. Use DateAdd function. This would be more flexible.
__________________
- -- --- ---- ----- ------ ------- ---------------
If you have knowledge, let others light their candles in it.
saadatshah is offline
Reply With Quote
View Public Profile Visit saadatshah's homepage!
 
Old 02-06-2007, 11:49 AM Re: Help with Years...
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
First off, while your solution is "correct", it's not the optimal. Try to use ASP functions as minimally as you can as every call to a built-in function does take up some server resource.

Do something like this instead:
Code:
Dim Start_Year, End_Year, i
Start_Year = Year (Date)
End_Year = Start_Year + 10
for i = Start_Year to End_Year
     Response.Write "<option>" & i & "</option>"
Next
One call to retrieve the year, one call to retrieve the date, no other functions necessary.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Reply     « Reply to Help with Years...
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.60777 seconds with 12 queries