Long Date Function
#1
Code: (Select All)
Function lDate$
    p$ = "th"
    If Val(Mid$(Date$, 4, 2)) <= 9 Then
        day$ = Right$(Mid$(Date$, 4, 2), 1)
    Else
        day$ = Mid$(Date$, 4, 2)
    End If
    If Val(Mid$(Date$, 4, 2)) = 1 Or Val(Mid$(Date$, 4, 2)) = 21 Or Val(Mid$(Date$, 4, 2)) = 31 Then p$ = "st"
    If Val(Mid$(Date$, 4, 2)) = 2 Or Val(Mid$(Date$, 4, 2)) = 22 Then p$ = "nd"
    If Val(Mid$(Date$, 4, 2)) = 3 Or Val(Mid$(Date$, 4, 2)) = 23 Then p$ = "rd"

    Select Case Val(Mid$(Date$, 1, 2))
        Case 1: Month$ = "January"
        Case 2: Month$ = "February"
        Case 3: Month$ = "March"
        Case 4: Month$ = "April"
        Case 5: Month$ = "May"
        Case 6: Month$ = "June"
        Case 7: Month$ = "July"
        Case 8: Month$ = "August"
        Case 9: Month$ = "September"
        Case 10: Month$ = "October"
        Case 11: Month$ = "November"
        Case 12: Month$ = "December"
    End Select
    lDate = day$ + p$ + " " + Month$ + " " + Mid$(Date$, 7, 4)
End Function
This code adds a function that will print a long date (21 February 2022) to the screen the instead of using date$ that would print 21-02-2022
Reply


Messages In This Thread
Long Date Function - by AtomicSlaughter - 05-21-2022, 09:20 PM
RE: Long Date Function - by Pete - 05-21-2022, 10:18 PM
RE: Long Date Function - by bplus - 05-24-2022, 08:22 PM



Users browsing this thread: 1 Guest(s)