VBA Macro
to know Number and Name of Day, Week, Month, Quarter in a given Date
By using the below VBA Macro, we can also know the Names of the Day, Week, Month of a given Date.
Sub
MyYear_Month_DayNames()
Dim X As String
Dim Y As String
X = #10/24/2012#
'To
Know Week Number (Eg: 4th Week) in the Current Year as of given Date
Y = Weekday(X)
MsgBox "Week
Number of the Month in given Date " & " " & X & "
" & " is: " & Y
'To
Know Weekday Name of the given Date
Y =
WeekdayName(Weekday(X))
MsgBox "Week
Name of the Month in given Date " & " " & X & "
" & " is: " & Y
'To
Know Month Number of the given Date
Y = Month(X)
MsgBox "Month
Number of the Month in given Date " & " " & X &
" " & " is: " & Y
'To
Know Month Name of the given Date
Y =
MonthName(Month(X))
MsgBox "Month
Name of the Month in given Date " & " " & X & "
" & " is: " & Y
'To
Know Year of the given Date
Y = Year(X)
MsgBox "Year of the given Date " & " " & X & " " &
" is: " & Y
'To
Know the Number of Day in the given Date
Y = Day(X)
MsgBox "The Number of Day in given Date" & "
" & X & " are: " & Y
'To
Know the Current Quarter of Year of given Date
Y = DatePart
("Q", X)
MsgBox "The
Current Quarter of the Year in given Date" & " " & X & " is: " &
Y
End Sub
Thanks,Tamatam
Thanks,Tamatam
No comments:
Post a Comment
Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.