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

how to get the system current year in ASP

Status
Not open for further replies.

hungnguyen

Programmer
Sep 22, 2000
43
US
Hi helper,

I am doing a website, but there is a need of a dropdown list for years, from the past 10 years upto the next 10 years of the current year. For example, this year is 2000; so that I would like to put into my dropdown menu from the year 1990 to 2010. This should be automatically calculated by the system clock. I did think many ways: VBScrip, JavaScript, and ASP. But they are not the final solution. Be side the question I ask above. There is anothe question. That is how to get the current year from the system in ASP. I know that to get the current system date is by the ASP code

<% date_test = date %>
but I do not know how to get the system current year directly (I meant without string concatination).
Thanks for your help.

Hung
 
Hung,

try this, it works for me =)

<html>
<body>
<select>
<%
past = Year(date()) - 10
future = Year(date()) + 10
for i= past to future
Response.Write(&quot;<option value=&quot; &i& &quot;>&quot; & i)
next
%>
</select>
</body>
</html>

hope this helps Chiu Chan
cchan@gefmus.com
 
or, if you are using server-side jscript, you could use:

d=new Date();
Response.write(d.getYear()) jared@aauser.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top