how to display day of week

J

Jason

i tried day(date) but that displays day of month. I tried help for
access 97 but help can't find veenlr3.hlp

Thanks,
Jason
 
J

Jason

found on the internet.
But is there a if inrange (0,15,30,45) instead of using if a=0 or a=15
or a=30 or a=45?
 
M

mbyerley

Jason said:
i tried day(date) but that displays day of month. I tried help for access
97 but help can't find veenlr3.hlp

Sub WhichDay()
MsgBox sDayOfWeek(vbSunday, Now())
End Sub

Function sDayOfWeek(iFirstDay As Integer, dDate As Date) As String
Select Case Weekday(dDate, iFirstDay)
Case vbSunday
sDayOfWeek = "Sunday"
Case vbMonday
sDayOfWeek = "Monday"
Case vbTuesday
sDayOfWeek = "Tuesday"
Case vbWednesday
sDayOfWeek = "Wednesday"
Case vbThursday
sDayOfWeek = "Thursday"
Case vbFriday
sDayOfWeek = "Friday"
Case vbSaturday
sDayOfWeek = "Saturday"
End Select
End Function
 
P

Pat Hartman

There are several ways to get the name of the weekday. Here"s two

Format(Date,"dddd")- the Format() function belongs in everyone's repertoire . It is used to format dates and numbers.

WeekDayName(Weekday(Date)) = this uses the WeekDay function to return the numeric day of the week (1-7) and then WeekDayName takes the value 1-7 and returns a day of the week.

You can adjust the starting day of the week with several of these functions. Take a look at the help entries for details.

Submitted via EggHeadCafe
Microsoft ASP.NET For Beginners
http://www.eggheadcafe.com/training-topic-area/ASP-NET/7/ASP.aspx
 
M

mbyerley

Jason said:
a much more efficient way

Definitely more sparse code, but negligible difference in performance.

The format function will also accomodate internationalization better than my
solution, which is strictly English regardless of locale.
 
P

Pat Hartman

The intention wasn't to make the code sparse or to make you look bad. Your solution works and there's a lot to be said for that. You also took the time and effort to help a fellow developer in need and I certainly wouldn't want to discourate that behavior. My intention was to point out the built in VBA functions which are there so you don't have to recreate the wheel. If you are going to use Access effectively, it is important to have some awareness of VBA functions. I've been writing programs for over 40 years. I've written my million lines of code and don't need the practice. I love working with Access because I appreciate what it does for me and I make every effort to take advantage of the environment.

Access 97 had good help entries for functions. They were listed by type and by name. But 2000, 2002, and 2003 were vast wastelands when you were looking for help. With 2007, help is getting back to what it was with 97. Obviously, if you don't know what function you are looking for, you won't know its name so the most useful function reference catagorizes so you can look through a smaller set of functions to find the one you need. If you are a beginner with VBA, it would be useful to bookmark this page so you can easily search the available functions for one that does what you need.

Submitted via EggHeadCafe
Microsoft SQL Server DBA For Beginners
http://www.eggheadcafe.com/training-topic-area/SQL-Server-DBA/6/SQL-Server-DBA.aspx
 
M

mbyerley

Hey.. No Worries. Check the smiley in my response to Rick.

Most of my VB has degraded to VBScript for old ASP stuff, so Format function
just didn't bubble to the surface, hence the long version.

I use mostly Delphi Pascal for non GUI helper (DLLs and console apps)
utilities, after the shift from straight VB to the VB.net stuff but I still
have a few in house things that I did in Access dating from 97, but I don't
get to mess with them much as they work when I use them.

Add to all that I am closer to 70 than 60, so I don't go at it hook and tong
so much any more.. ;-) but I ain't dead yet, so I likely will lurk for a
while longer.
 
J

Jason

already done that, now i get: can not find the veenlr3.hlp file. do you
want to try to find the file yourself?
Search never found it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top