473,404 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

weeknumber in sql??

DD
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
Nov 12 '05 #1
5 8506
Something like this?

SELECT [theDate] & " is in " & Format([theDate],"w") & "th wheek of year"
AS Weekday FROM theTable;
"DD" <ad@ad.nl> escreveu na mensagem
news:bn**********@news4.tilbu1.nb.home.nl...
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

Nov 12 '05 #2
"DD" <ad@ad.nl> wrote in message news:<bn**********@news4.tilbu1.nb.home.nl>...
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


Something like...
Public Function WeekNumber(ByVal dtDate As Date) As Integer
WeekNumber = DateDiff("w", DateSerial(Year(dtDate), 1, 1), dtDate) + 1

End Function

....maybe?

Or were you thinking of a pure SQL function?
Nov 12 '05 #3
On Fri, 31 Oct 2003 15:48:03 +0100, "DD" <ad@ad.nl> wrote:

Use the DateDiff function, especially the last two arguments.
Reasonable people can disagree on what constitutes week 1. Make sure
you make the right selection for your situation.

-Tom.

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


Nov 12 '05 #4
Access or Sql Server?

For Sql Server you can do this:

SELECT 'Week ' + datename(wk, myTable.myField)) AS 'someWeek'
FROM myTable

As for Access - I looked around for a while, but didn't see any built in
functions that would do it. One of the others recommendations might work
there.


"DD" <ad@ad.nl> wrote in message
news:bn**********@news4.tilbu1.nb.home.nl...
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

Nov 12 '05 #5
Access - DatePart("ww", myTable.myField) As WeekOfYear

--
MGFoster:::mgf
Oakland, CA (USA)
Jerry Boone wrote:
Access or Sql Server?

For Sql Server you can do this:

SELECT 'Week ' + datename(wk, myTable.myField)) AS 'someWeek'
FROM myTable

As for Access - I looked around for a while, but didn't see any built in
functions that would do it. One of the others recommendations might work
there.


"DD" <ad@ad.nl> wrote in message
news:bn**********@news4.tilbu1.nb.home.nl...
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



Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
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
3
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...
2
by: | last post by:
Hi!! know someone how to get a week span with week number and year? something like hi: public static DateTime GetWeekSpan(int weekNumber, int year) { DateTime weekStartDate = new...
10
by: bjaj | last post by:
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...
4
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...
4
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...
1
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: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
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...
0
marktang
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,...
0
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...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.