Applecore Pages on Microsoft Access

Formatting Cardinal Dates

If you wish to display cardinal dates, for example 1st January 2001, then you will need a short function to return the correctly formatted date. An example would be:

Function fCardinalDate(dtmDate As Date) As String
    Select Case Day(dtmDate)
        Case 1,21,31
            fCardinalDate=Day(dtmDate) & "st" & Format(dtmDate,"mmmm") & " " & Year(dtmDate)
        Case 2,22
            fCardinalDate=Day(dtmDate) & "nd" & Format(dtmDate,"mmmm") & " " & Year(dtmDate)
        Case 3,23
            fCardinalDate=Day(dtmDate) & "rd" & Format(dtmDate,"mmmm") & " " & Year(dtmDate)
        Case Else
            fCardinalDate=Day(dtmDate) & "th" & Format(dtmDate,"mmmm") & " " & Year(dtmDate)
    End Select
End Sub

This function will return the date in the format '1st January 2001'. Obviously, if you want the date in a slightly different format, then you will need to alter the function as required.

Top

 


HOME | NEW | TABLES | QUERIES | FORMS | REPORTS | GENERAL | API | DOWNLOADS | TUTORIAL | RESOURCES
E-MAIL
Copyright & Disclaimer

 

Last modified at 06/06/2006 14:54:29