get the name of the day such as monday.

Posted on 2004-11-09
Last Modified: 2010-05-02
I am trying to get the day of the week returned programmatically visual basic.
I know how to get the date and time stamp. What I need it to tell me is the date, time and the day of the week.  Then I can schedule due dates for projects that span over a weekend.
I know there is the calendar control but I am not using any forms for this project so I do not know what to do
Question by:shayne23d
    LVL 32

    Expert Comment

    'Get the day of the week (1 to 7)
    Debug.Print Weekday(Now, vbSunday)
    LVL 32

    Expert Comment

    'Get the day of the month
    Debug.Print DatePart("d", Now)
    LVL 48

    Expert Comment

    msgbox  Format(Now, "dddd, mmmm dd, yyyy")
    LVL 48

    Accepted Solution

    Printing Formatted Dates and Times
    To print formatted dates and times, use the Format function with symbols representing date and time. These examples use the Now and Format functions to identify and format the current date and time. The following examples assume that the Regional Settings dialog box of the Windows Control Panel is set to "English(United States)".

    Format syntax Result
    Format(Now, "m/d/yy") 1/27/93
    Format(Now, "dddd, mmmm dd, yyyy") Wednesday, January 27, 1993
    Format(Now, "d-mmm") 27-Jan
    Format(Now, "mmmm-yy") January-93
    Format(Now, "hh:mm AM/PM") 07:18 AM
    Format(Now, "h:mm:ss a/p") 7:18:00 a
    Format(Now, "d-mmmm h:mm") 3-January 7:18

    By using the Now function with the format "ddddd" and "ttttt, " you can print the current date and time in a format appropriate for the selection in the Regional Settings dialog box of the Windows Control Panel
    LVL 32

    Expert Comment

    'Get the name of the weekday
    Debug.Print WeekdayName(Weekday(Now, vbSunday), False)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
    Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now