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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format([DAG];"ww")

Status
Not open for further replies.

phpatrick

Programmer
Jul 9, 2006
72
BE
Perhaps an easy one, but I can't find.
Looking for the weeknumber, this works but start on Sunday.
European weeks start from Monday.
I uses vbMonday, but syntaxis is refuses.
Any ID
 
vbMonday 2 Monday

I used 2, now it start from monday, but next problem is that he add a weeknumber week 31 becomes 32 witch is not correct.
Should you do something with firstweekofyear ?

Code:
DatePart ( interval, date, [firstdayofweek], [firstweekofyear])
 
perhaps not the best way, but this works
Code:
WEEK1: DatePart("ww";[DAG];2)-1
 
What's with the semi colon? Format([DAG];,"ww")

intWW = Weekday([DAG],vbMonday)??

Work around...

intww = Switch(intww = 1,7,intww = 2,1,intww = 3,2,.....
intww = 7,6)
 
ww" returns the week of the year and the options for that in the Format statement are an interaction between the third and fourth arguments.
Code:
[b]Fourth Argument[/b]
vbUseSystem           0
vbFirstJan1           1
vbFirstFourDays       2
vbFirstFullWeek       3

[b]vbSunday = 1[/b]
Format(#2006-08-13#,"ww",1,0)   ==> 33
Format(#2006-08-13#,"ww",1,1)   ==> 33
Format(#2006-08-13#,"ww",1,2)   ==> 33
Format(#2006-08-13#,"ww",1,3)   ==> 33

[b]vbMonday = 2[/b]
Format(#2006-08-13#,"ww",2,0)   ==> 33
Format(#2006-08-13#,"ww",2,1)   ==> 33
Format(#2006-08-13#,"ww",2,2)   ==> 32
Format(#2006-08-13#,"ww",2,3)   ==> 32
The VBA constants like vbSunday, vbMonday, ... are not recognized in SQL so you need to use their numeric equivalents.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top