how to get just last two digits of the year?

# Thread: how to get just last two digits of the year?

1. dep
Senior Member
Join Date
Dec 1969
Posts
709

## how to get just last two digits of the year?

Hello. I have this code:<BR><BR>&#060;SCRIPT LANGUAGE="JavaScript"&#062;<BR>&#060;!-- Begin<BR>Stamp = new Date();<BR>year = Stamp.getYear();<BR>if (year &#060; 2000) year = 1900 + year;<BR>document.write(&#039;&#060;input type="text" name="prjStartDate" value="&#039; + (Stamp.getMonth() + 1) +"/"+Stamp.getDate()+ "/"+ year + &#039;" "maxlength=15 style="font-family: helvetica; color: black; background-color: white; font-size: 8pt; width: 100px;" size="20"&#062;&#039;)<BR>// End --&#062;<BR>&#060;/SCRIPT&#062;<BR><BR>but I just want it to display the date as dd/mm/yy -- any idea on how to modify this code? or how to do it?<BR>

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

## Right(year(), 2)

.

3. dep
Senior Member
Join Date
Dec 1969
Posts
709

## that is, instead of dd/mm/yyyy :) <NT>

.

4. dep
Senior Member
Join Date
Dec 1969
Posts
709

## RE: Right(year(), 2)

Right.. where does that go? :)

5. Senior Member
Join Date
Dec 1969
Posts
2,092

## RE: Right(year(), 2)

Dim theYear<BR>theYear = Year(Date())<BR><BR>Dim lasttwodigitsforyear<BR>lasttwodigitsforyear = Right(theYear, 2)

6. Senior Member
Join Date
Dec 1969
Posts
96,118

## Ummm...

...for USA, that should be the default.<BR><BR>Response.Write Date()<BR><BR>should just give you 12/14/01<BR><BR>Does it not?<BR><BR><BR><BR>

7. dep
Senior Member
Join Date
Dec 1969
Posts
709

## worked like a dream! thanks! <nt>

.

8. dep
Senior Member
Join Date
Dec 1969
Posts
709

## Nope.. 4 digit year. <nt>

.

#### Posting Permissions

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