Hi
I have made this msgbox to display the current Week number, but it
shows the wrong weekno.
Can anyone tell me why ?
msg = "WeekNumber: " & DatePart("WW", Date)
MsgBox msg
It shows weekno = 47 for the date 16 november 2005, but it should be
46.
best regards
Ronald 10 5242
Look at the Help
Maybe you need to use:
msg= "WeekNumber: " & DatePart("WW", Date , , vbFirstFullWeek) ?
The return value of DatePart depends on what is to be considered as the first day in a given week.
Also Access needs to know what is considered as the first week.
Arno R
<bj**@vestas.com> schreef in bericht news:11**********************@f14g2000cwb.googlegr oups.com... Hi I have made this msgbox to display the current Week number, but it shows the wrong weekno. Can anyone tell me why ? msg = "WeekNumber: " & DatePart("WW", Date) MsgBox msg It shows weekno = 47 for the date 16 november 2005, but it should be 46. best regards Ronald bj**@vestas.com wrote: Hi
I have made this msgbox to display the current Week number, but it shows the wrong weekno. Can anyone tell me why ?
msg = "WeekNumber: " & DatePart("WW", Date) MsgBox msg
It shows weekno = 47 for the date 16 november 2005, but it should be 46.
Check out the 4th parameter to the DatePart function, you should find
what you are looking for for week numbers.
Hi
Thank both of you. The 4th parameter was the clue.
Thank you wery mutch.
Ronald
Hi again.
I also got a query with this SQL phrase:
SELECT Q_AfsluttedeRepIntern.InitSag,
Count(Q_AfsluttedeRepIntern.InitSag) AS CountOfInitSag,
Format$(T_FejlRecords.DatoAfsl,'ww\/yyyy') AS [DatoAfsl By Week]
FROM Q_AfsluttedeRepIntern
GROUP BY Q_AfsluttedeRepIntern.InitSag,
Format$(T_FejlRecords.DatoAfsl,'ww\/yyyy');
How shall I do to secure that VB count the weekno. from the first full
week of year ?
best regards
Ronald
Ronald,
Use the same 'trick'. Look in the Help for Format()
Arno R
<bj**@vestas.com> schreef in bericht news:11**********************@g43g2000cwa.googlegr oups.com... Hi again. I also got a query with this SQL phrase: SELECT Q_AfsluttedeRepIntern.InitSag, Count(Q_AfsluttedeRepIntern.InitSag) AS CountOfInitSag, Format$(T_FejlRecords.DatoAfsl,'ww\/yyyy') AS [DatoAfsl By Week] FROM Q_AfsluttedeRepIntern GROUP BY Q_AfsluttedeRepIntern.InitSag, Format$(T_FejlRecords.DatoAfsl,'ww\/yyyy'); How shall I do to secure that VB count the weekno. from the first full week of year ? best regards Ronald
Hi Arno and thank you!
I know I am a novice i VBA versus Access, so I need more help.
I tryed this:
Set oDB = CurrentDb
Set oQuery = oDB.QueryDefs("Q_3monthBack_Prod")
VareVar = InputBox("Indtast varenr.:", "Indtast")
mySQL = "SELECT Q_AfsluttedeRepIntern.InitSag,
Count(Q_AfsluttedeRepIntern.InitSag)" & _
"AS CountOfInitSag,
Format$(T_FejlRecords.DatoAfsl,'ww yyyy',, vbFirstFullWeek) AS
[DatoAfsl By Week]" & _
"FROM Q_AfsluttedeRepIntern GROUP BY
Q_AfsluttedeRepIntern.InitSag, Format$(T_FejlRecords.DatoAfsl,'ww
yyyy',, vbFirstFullWeek)"
oQuery.SQL = mySQL
Set oQuery = Nothing
Set oDB = Nothing
DoCmd.OpenReport "R_3MonthBack_Prod", acViewPreview
-and got this message:
Syntax error (missing operator) in query expresion
'Format$(T_FejlRecords.DatoAfsl,'ww yyy',,vbFirstFullWeek)'.
What is missing or wrong ?
Please help me !
Best regards
Ronald
Ronald,
I think with Format$ used in a query, when you use the 4th param you also need to supply the 3rd (StartDay)
Also you need to use the numeric values here:
So I guess Format$(T_FejlRecords.DatoAfsl,'ww yyyy', 1, 3) will work? (I use yyyy, not yyy)
The Constant "1" here means that the week starts at Sunday. (use 2 for Monday)
3 for the last param 'means' the same as vbFirstFullWeek. Again look at the Help for this.
I have a little difficulty here reading your code (my eyes are hazy at the moment ...) but I see some problems here:
-- I don't understand where you use your Inputbox (VareVar)
-- Also you are not using the SQL-string that you are constructing?
Apparently you are changing the SQL of a saved query but you close the query before using it.
==>> oQuery.SQL = mySQL
==>> Set oQuery = Nothing
What exactly are you trying to do, and where are you using this code ??
Is this oQuery.SQL meant to be the recordset for your report??
Btw: As a novice I guess you might be better off using a 'plain' query as the recordset for your report.
Arno R
<bj**@vestas.com> schreef in bericht news:11**********************@f14g2000cwb.googlegr oups.com... Hi Arno and thank you! I know I am a novice i VBA versus Access, so I need more help. I tryed this: Set oDB = CurrentDb Set oQuery = oDB.QueryDefs("Q_3monthBack_Prod") VareVar = InputBox("Indtast varenr.:", "Indtast") mySQL = "SELECT Q_AfsluttedeRepIntern.InitSag, Count(Q_AfsluttedeRepIntern.InitSag)" & _ "AS CountOfInitSag, Format$(T_FejlRecords.DatoAfsl,'ww yyyy',, vbFirstFullWeek) AS [DatoAfsl By Week]" & _ "FROM Q_AfsluttedeRepIntern GROUP BY Q_AfsluttedeRepIntern.InitSag, Format$(T_FejlRecords.DatoAfsl,'ww yyyy',, vbFirstFullWeek)" oQuery.SQL = mySQL Set oQuery = Nothing Set oDB = Nothing DoCmd.OpenReport "R_3MonthBack_Prod", acViewPreview -and got this message: Syntax error (missing operator) in query expresion 'Format$(T_FejlRecords.DatoAfsl,'ww yyy',,vbFirstFullWeek)'. What is missing or wrong ? Please help me ! Best regards Ronald
Hi Arno
It works with numbers instead of constantnames. Thank you
The code ?
It was taken from some other place where the SQL statement is
different. I shall use the new SQL in a similar way.
And yes, the code is meant to be the recordset for a report.
best regards
Ronald
Arno R wrote: I have a little difficulty here reading your code (my eyes are hazy at the moment ...) but I see some problems here:
The police officer pulled the smart aleck over.
Officer: You're eyes look a little hazy. Have you been drinking?
Smart Aleck: Your eyes look a little glazed. Have you been eating
doughnuts?
James A. Fortune
On 16 Nov 2005 00:07:06 -0800, bj**@vestas.com wrote: Hi
I have made this msgbox to display the current Week number, but it shows the wrong weekno. Can anyone tell me why ?
msg = "WeekNumber: " & DatePart("WW", Date) MsgBox msg
It shows weekno = 47 for the date 16 november 2005, but it should be 46.
best regards
Ronald
Beware of this gotcha -
BUG: Format or DatePart Functions Can Return Wrong Week Number for Last Monday in Year http://support.microsoft.com/default...b;en-us;200299 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Stig Andersen |
last post by:
Hi does anyone know how to make MS SQL server 2000 calculate the right week
number around new year ?
According to the help file, MSSQL should follow ISO8601, which ensures that
i.e. 2003 has...
|
by: Vanessa |
last post by:
Does anyone know whether when I select a weeknumber of a certain year, eg.
2004, the date from first day to the last day of the week will be known.
Regards
Vanessa
|
by: DD |
last post by:
Hi there,
I am working on a sql-query and I need to know the weeknumber of a given
date. Could anyone please help me with this.
Thanks in advance,
Arjen
|
by: dik mus |
last post by:
Hi,
I connect to a database that only stores the year and weeknumber. But i need
the date of the corresponding monday.
This could be more difficult as one expect because the weekumbers might...
|
by: Soren Jorgensen |
last post by:
Hi,
Following code should give the number of weeks in years 1998-2010 for a
Danish calendar (on a Danish box)
GregorianCalendar cal = new GregorianCalendar();
for(int i = 1998; i < 2010; i++)...
|
by: Morten Snedker |
last post by:
In Denmark the 1/1/2009 belongs to week 53 of year 2008.
The code below, as I believe should apply to Danish settings, returns
1, which is wrong.
Am I having a wrong approach?
'--code...
|
by: khicon73 |
last post by:
Hello All,
I would like to calculate weeknumber and period from first day of the week (sunday) and last day of the week (saturday) and week number falls from 1 to 52 only. If week number >= 53 then...
|
by: Longkhi |
last post by:
Hi Everybody.
I'm developing a dentist program, which contains a MonthCalender. I would like to select a specific weeknumber, when I select a weeknumber in the MC. I can show the weeknumbers by...
|
by: peetersb |
last post by:
Hi,
I want ot make functions like this:
int getFirtDayOfWeek(int weeknumber, int year);
int getLastDayOfWeek(int weeknumber, int year);
Firts I calculate the count of weeks like this:
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |