Steve's stupid coding tricks #2

# Thread: Steve's stupid coding tricks #2

1. Member
Join Date
Dec 1969
Posts
84

## Steve's stupid coding tricks #2

Hi,<BR><BR>I recently posted a stupid coding trick that you didn&#039;t need.<BR><BR>Here&#039;s another one:<BR><BR>I&#039;m regularly pissed off by sites that ask for credit cards expiration dates and offer years that preceed the present.<BR><BR>So here&#039;s the select statement that solves the problem. To not have something like this is sloppy.<BR><BR>&#060;select name="cyear"&#062;<BR>&#060;option&#062;&#060;%=ri ght(year(now),2)%&#062;<BR>&#060;option&#062;&#060 ;%=right(year(now)+1,2)%&#062;<BR>&#060;option&#06 2;&#060;%=right(year(now)+2,2)%&#062;<BR>&#060;opt ion&#062;&#060;%=right(year(now)+3,2)%&#062;<BR>&# 060;option&#062;&#060;%=right(year(now)+4,2)%&#062 ;<BR>&#060;option&#062;&#060;%=right(year(now)+5,2 )%&#062;<BR>&#060;option&#062;&#060;%=right(year(n ow)+6,2)%&#062;<BR>&#060;/select&#062;<BR><BR>Like wise, your copyright notice on the bottom of each screen should automatically update to the current year.<BR><BR>&#060;FONT SIZE="-2" FACE="Verdana"&#062;&copy;1998-&#060;%=year(now())%&#062; - &#060;BYourCompany&#060;/B&#062;&#060;/font&#062;

2. Senior Member
Join Date
Dec 1969
Posts
2,493

## RE: Steve's stupid coding tricks #2

How about<BR><BR>&#060;select name="cyear"&#062;<BR>&#060;%<BR>sYear=Right(Year( Date),2)<BR>for i = sYear to (sYear+6)<BR>Response.write "&#060;option&#062;" Left(("0" & i),2)<BR>next<BR>%&#062;<BR>&#060;/select&#062;

3. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## What makes you think

that is NOT how they have it set up rt now??<BR><BR><BR>

4. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

Cause it is buggy<BR><BR>&#062;Response.write "&#060;option&#062;" Left(("0" & i),2)<BR>No prizes if you figure it out<BR><BR>:)

5. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## OR

&#060;select name="cyear"&#062;<BR>&#060;%<BR>lYear=Year(Date)< BR>for i = lYear to lYear + 6<BR>Response.write "&#060;option&#062;" & i & "&#060;/option&#062;"<BR>next<BR>%&#062;<BR>&#060;/select&#062;<BR><BR><BR><BR>ofcourse you CAN add the bit to get a 2 digit year.....i reason i did not is cause i expect the setting to return a 4 digit year<BR><BR>

6. Senior Member
Join Date
Dec 1969
Posts
2,493

## I normally doit your way also....

but he was going for 2 digit year<BR>I haven&#039;t had enough coffee this morning , the only problem I see in mine is when it hit 1/1/3000.

7. Senior Member
Join Date
Dec 1969
Posts
2,493

## I see

It should be right(("0" & i),2)<BR><BR>not left<BR><BR>see what coffee can do for you

8. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## Wrong again

wanna try for the THIRD time<BR><BR><BR>

9. Senior Member
Join Date
Dec 1969
Posts
2,493

## RE: Wrong again

Well I just did<BR><BR>SYear=Right(Year(Date),2)<BR>for i = sYear to sYear+1000<BR>response.write Right(("0" & i),2) & "<BR>"<BR>next<BR><BR>and the only thing was repeated years due to the 2 digits<BR><BR><BR>so why keep me in suspense just hit me upside the head with it :)<BR><BR>

10. Senior Member
Join Date
Dec 1969
Location
Los Angeles, CA
Posts
21,192

## LOL

you said<BR><BR>response.write "&#060;option&#062;" left(....<BR><BR><BR><BR>you MISSED the & <BR><BR>:)<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•