Is this an error or intentional?

C

Colin Steadman

Just looking up a way to convert dates to Oracle format and found this
function in the forum:

<SCRIPT language="vbscript" runat="server">
Function ConvertToOracleDate(dtmDate)
If IsDate(dtmDate) Then
Dim arData(2)
arData(0) = Right("00" & Day(dtmDate),2)
arData(1) = UCase(MonthName(Month(dtmDate),True))
arData(2) = Year(dtmDate)
ConvertToOracleDate = Join(arData," ")
End If
End Function
</SCRIPT>

It works fine, but I cant understand why this line:

arData(0) = Right("00" & Day(dtmDate),2)

includes the "00" string in the right function. Does it serve some
purpose, or is it a mistake.

TIA,

Colin
 
A

Aaron Bertrand - MVP

Because you need a leading zero. So, if the day is 5, the string becomes
005, and you take the right two digits. If the day is 24, it becomes 0024,
and you take the right two digits.

I suppose, really, it could just be a single 0.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top