INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# work with end number

## work with end number

(OP)
Hello gang, I hope all is well in your world.

I want to be able to work with the end digit in the days of the year, and have an if/then to make it be a nd, st, rd, ect.

So it would read "This is the 222nd day of the year."
I have the code to get the day of the year using

#### CODE

<%=DateDiff("d",DateSerial(Year(Now),1,1),Date)%>
I just need to add the suffix variable somehow.

Any ideas??

### RE: work with end number

#### CODE --> vBscript

Function addOrdinalString(p_iVal)
sNum = cStr(p_iVal)
iNum = p_iVal mod 10
select case iNum
case 1
sOrd = "st"
case 2
sOrd = "nd"
case 3
sOrd = "rd"
case else '4,5,6,7,8,9,0
sOrd = "th"
end select
' deal with the teens
if p_iVal > 10 and p_iVal <20 then sOrd = "th"
sNum = sNum & sOrd
End Function 

It was only intended to handle 1 to 31 (for obvious reasons) but should tweak for > 100 upwards with a bit of code to strip off the first character (the hundreds) from p_iVal if > 99, add the ordinal, then concatenate the leading character back on.

I would do that myself but I don't have a Windows machine to test on, plus it's 4:AM and I'm running on tea and Ginger Nuts.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

### RE: work with end number

(OP)
lol, get some sleep dude!!

I will try this in the morning as I am heading to bed. Since the stroke, I sleep at least 10 hours a night.

Thanks a ton and I will let you know of the outcome.

### RE: work with end number

(OP)
Could not get it to work. I will try more tomorrow when I have more time

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!