473,948 Members | 21,799 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8537
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.tilbu 1.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(ByVa l 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
1372
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
1903
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 change from country to country. (I am looking for a dutch solution.) Thanks, dik
2
1089
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 DateTime(); DateTime weekEndDate = new DateTime();
10
5302
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 weekno = 47 for the date 16 november 2005, but it should be
4
4718
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 week number will equal to 52. And Last Day of First week is the first Saturday of January, as long as it falls at least four days into the month Example: if enter Date WeekNo. Period 12/31/06 1 12/31/06-01/06/07 01/05/07 1 12/31/06-01/06/07...
4
1923
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 the code: this.monthCalender1.ShowWeekNumbers = true; Is it possible to make such function? Best regards
1
2627
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: DateTime lastDay = new DateTime(DateTime.Now.Year, 12, 31);
0
11589
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11183
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11358
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
8261
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7434
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6122
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4952
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4545
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.