microsoft access help database programing developer
Back to Access Experts About Access Experts Access Experts Websites Access Experts Team Access Experts Services Access Experts Case Studies Access Expert Tips Contact Access Experts OUR BLOG
 
 
Spell out date, i.e., "September 1st, 2009"
by Juan Soto
09/02/2009

Use these functions to spell out the date in your reports and forms

Use this function to spell out the current date in your reports and forms.

Public Function GetYearMonthDay() As String
'---------------------------------------------------------------------------------------
' Procedure : GetMonthName
' Author    : AccessExperts.net

    ' This function will return today's month and day in this format. "August 22nd, 2005"
    GetYearMonthDay = GetMonthName(month(Date)) & " " & GetDayName(Day(Date)) & ", " & Year(Date)

End Function


Public Function GetMonthName(month As Integer) As String
'---------------------------------------------------------------------------------------
' Procedure : GetMonthName
' Author    : AccessExperts.net

    ' This function returns the month name based on its number.
    Select Case month
        Case 1
            GetMonthName = "January"
        Case 2
            GetMonthName = "February"
        Case 3
            GetMonthName = "March"
        Case 4
            GetMonthName = "April"
        Case 5
            GetMonthName = "May"
        Case 6
            GetMonthName = "June"
        Case 7
            GetMonthName = "July"
        Case 8
            GetMonthName = "August"
        Case 9
            GetMonthName = "September"
        Case 10
            GetMonthName = "October"
        Case 11
            GetMonthName = "November"
        Case 12
            GetMonthName = "December"
    End Select

   On Error GoTo 0
   Exit Function

GetMonthName_Error:

   msgbox err.description
End Function


Public Function GetDayName(lngDay As Long) As String
    ' This function will return the day's suffix based on its number. For example: "22nd"
    Select Case lngDay
        Case 1, 21, 31
            GetDayName = lngDay & "st"
        Case 2, 22
            GetDayName = lngDay & "nd"
        Case 3, 23
            GetDayName = "3rd"
        Case 4 To 20, 24 To 30
            GetDayName = lngDay & "th"
       
    End Select
End Function


If you like this tip you will be delighted with our service! Call or write us today for a free quote regarding your computer needs.

Publish this article in your own corporate newsletter or publication! Contact us to obtain a free license.


Home | About Us Why PCExperts | Team | Services | Newsletter | Contact Us
Copyright © 2004