Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Only need part of a date 1

Status
Not open for further replies.

mxp346

MIS
Apr 27, 2002
50
0
0
US
I have a field called DueDate in a table called Assignments. I have the field set up as a Long Date so that the full date is kept for historical data. I'm running some VB code that needs to just look at the day of the week, not the full date. Is there VB code that can take out just the day of the week from the Long Date?
 
Try the weekday function! =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
First off, you don't need to set it up as a "full date" so to speak - every DATE field is a "full date" (and TIME, for that matter) - FULL date, short date, and, for all I know, Blind Date and Broken Date are just ways to DISPLAY the date information.

When you enter a DATE part only into a date/time datatype, the TIME portion of the number is set to midnight of the DATE being entered. If you enter only a TIME portion to a date/time field, the DATE part of the number is set to the current day. If you don't enter a year part, it's set to the current YEAR. If you don't enter a month part, it's set to the current month. If you don't enter a DAY part, it's set to the FIRST of the month part given.

Thus
Nov 2002 --- stored as 11/01/2002 00:00:00
11/21 --- stored as 11/21/2002 00:00:00
11:33 --- stored as 11/21/2002 23:33:00
11/22 3PM -- stored as 11/22/2002 15:00:00

Thus, no matter HOW YOU ENTER A DATE/TIME, if you follow the date/time settings, Access will be able to tell what is what, e.g. your Control Panel's M/D/Y or D/M/Y setting.

Weekday(#11/21/02#) will return 5 - Thursday is the FIFTH day of the week, at least when you accept the default SUNDAY being Day #1

And of course, the ever-popular FORMAT("dddd", #11/21/02#) will give you back the "Thursday" you might also be looking for.

Jim
















Me? Ambivalent? Well, yes and no....
Another free Access forum:
More Access stuff at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top