Convert date to the English spelling [Closed]

Report
-
Posts
2776
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
July 26, 2021
-
Hello,
My date of birth
1-3-1995
Please convert to the English spelling



1 reply

Posts
2776
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
July 26, 2021
465
Hi Hassanuddin,

Consider using this adjusted SpellNumber function:
Function NTT(ByVal MyNumber)
Dim Temp

If Len(MyNumber) = 1 Then
    Temp = GetDigit(MyNumber)
    GoTo exitFunction
End If

If Len(MyNumber) > 2 Then
    Temp = GetTens(Left(MyNumber, 2)) & " Hundred "
End If

Temp = Temp & GetTens(Right(MyNumber, 2))

exitFunction:
NTT = Temp
End Function

' Converts a number from 10 to 99 into text.
Function GetTens(TensText)
    Dim Result As String
    Result = ""           ' Null out the temporary function value.
    If Val(Left(TensText, 1)) = 1 Then   ' If value between 10-19...
        Select Case Val(TensText)
            Case 10: Result = "Ten"
            Case 11: Result = "Eleven"
            Case 12: Result = "Twelve"
            Case 13: Result = "Thirteen"
            Case 14: Result = "Fourteen"
            Case 15: Result = "Fifteen"
            Case 16: Result = "Sixteen"
            Case 17: Result = "Seventeen"
            Case 18: Result = "Eighteen"
            Case 19: Result = "Nineteen"
            Case Else
        End Select
    Else                                 ' If value between 20-99...
        Select Case Val(Left(TensText, 1))
            Case 2: Result = "Twenty "
            Case 3: Result = "Thirty "
            Case 4: Result = "Forty "
            Case 5: Result = "Fifty "
            Case 6: Result = "Sixty "
            Case 7: Result = "Seventy "
            Case 8: Result = "Eighty "
            Case 9: Result = "Ninety "
            Case Else
        End Select
        Result = Result & GetDigit _
            (Right(TensText, 1))  ' Retrieve ones place.
    End If
    GetTens = Result
End Function
     
' Converts a number from 1 to 9 into text.
Function GetDigit(Digit)
    Select Case Val(Digit)
        Case 1: GetDigit = "One"
        Case 2: GetDigit = "Two"
        Case 3: GetDigit = "Three"
        Case 4: GetDigit = "Four"
        Case 5: GetDigit = "Five"
        Case 6: GetDigit = "Six"
        Case 7: GetDigit = "Seven"
        Case 8: GetDigit = "Eight"
        Case 9: GetDigit = "Nine"
        Case Else: GetDigit = ""
    End Select
End Function


Then in Excel use the formula:
=ntt(DAG(A1)) & " " & BEGINLETTERS(TEKST(A1;"Mmmm")) & " " &ntt(JAAR(A1))
or if you are using a non dutch version:
=ntt(DAY(A1)) & " " & PROPER(TEXT(A1,"Mmmm")) & " " &ntt(YEAR(A1))


Kom je er zo uit?

Best regards,
Trowa

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!