Format the date type value : Date Format « Date Functions « VBA / Excel / Access / Word






Format the date type value

 
Sub FindDates()
    On Error GoTo errorHandler
    Dim startDate As String
    Dim stopDate As String

    startDate = Format("12/12/1900", "mm/??/yy")
    stopDate = Format("12/12/2000", "mm/??/yy")

    MsgBox startDate
   
    End
    errorHandler:
    MsgBox "There has been an error:  " & Error() & Chr(13) _
        & "Ending Sub.......Please try again", 48
End Sub

 








Related examples in the same category

1.Format time as mmmm_yyyy
2.formatting the date and time with format function
3.Using the Format Function to Format an Expression: Format(expression[, format[, firstdayofweek[, firstweekofyear]]])
4.: - Time separator (typically a colon, but this depends on the locale).
5./ Date separator (also locale-dependent).
6.c - Displays the date
7.d - Displays the date (1 to 31) without a leading zero for single-digit numbers.
8.dd - Displays the date with a leading zero for single-digit numbers (01 to 31).
9.ddd - Displays the day as a three-letter abbreviation (Sun, Mon, Tue, Wed, Thu, Fri, Sat) with no period.
10.dddd - Displays the full name of the day.
11.ddddd - Displays the complete date (day, month, and year) in the system's short date format.
12.dddddd - Displays the complete date (day, month, and year) in the system's long date format.
13.aaaa - Displays the full, localized name of the day.
14.w - Displays an integer from 1 (Sunday) to 7 (Monday) containing the day of the week.
15.ww - Displays an integer from 1 to 54 giving the number of the week in the year.
16.m - Displays an integer from 1 to 12 giving the number of the month without a leading zero on single-digit months.
17.mm - Displays a number from 01 to 12 giving the two-digit number of the month. When used after h returns minutes instead of months.
18.mmm - Displays the month as a three-letter abbreviation (except for May) without a period.
19.mmmm - Displays the full name of the month.
20.oooo - Displays the full localized name of the month.
21.q - Displays a number from 1 to 4 giving the quarter of the year.
22.y - Displays an integer from 1 to 366 giving the day of the year.
23.yy - Displays a number from 00 to 99 giving the two-digit year.
24.yyyy - Displays a number from 0100 to 9999 giving the four-digit year.
25.h - Displays a number from 0 to 23 giving the hour.
26.Hh - Displays a number from 00 to 23 giving the two-digit hour.
27.N - Displays a number from 0 to 60 giving the minute.
28.Nn - Displays a number from 00 to 60 giving the two-digit minute.
29.S - Displays a number from 0 to 60 giving the second.
30.Ss - Displays a number from 00 to 60 giving the two-digit second.
31.ttttt - Displays the full time (hour, minute, and second) in the system's default time format.
32.AM/PM - Uses the 12-hour clock and displays AM or PM as appropriate.
33.A/P - Uses the 12-hour clock and displays A or P as appropriate.
34.AMPM - Uses the 12-hour clock and displays the AM or PM string literal defined for the system.
35.For example, the following statement returns Saturday, April 01, 2006:
36.format(Now, "d-mmm-yy")
37.format(Now, "d-mmmm-yy")
38.format(Now, "mmmm d, yyyy")
39.format(Now, "ddd")
40.format(Now, "dddd")
41.format(Now, "ddddd")
42.format(Now, "dddddd")
43.Format(Now, "Hh:Nn:Ss AM/PM")
44.Format(Now, "ttttt")
45.Format(datDateTime, "Long Date")
46.Format(datDateTime, "dd mmm yy")
47.Format(datDateTime, "yyyy-mm-dd")
48.Format(datDateTime, "mm dddd hh:mm")