473,394 Members | 1,761 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,394 software developers and data experts.

datepart function

I am creating a booking system in ASP.Net with VB and a MSSQL backend.

I am having problems knowing where to begin with a particular part of the
system. Bookings can only be made in weekly multiples from Saturday to
Saturday.

The only way I can think of to do it is by manually adding the weeks into a
table in the DB, but this will obviously mean that I will have to routinely
update this table.

Is there any way to cope with this problem programmatically? The most
suitable solution would be to write a chunk of code that the site
administrator can run every once in a while to automatically populate a table
with the weeks (this table will need to store a Week ID and a Start Date)....

Any ideas!!!!???? I'm stuck!!
Nov 19 '05 #1
2 2001
Plug the following into your Query Analyzer. It should give you an idea of
what to do:

set datefirst 6
declare @dt DateTime
declare @dj1 DateTime
Set @dt = GetDate()
Set @dj1 = 'Jan 1, 2005'
select datepart(wk, @dt)
select datename(dw, @dt), datepart(dw, @dt)
select datepart(wk, @dj1)
select datename(dw, @dj1), datepart(dw, @dj1)

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
A watched clock never boils.

"Aaran76" <Aa*****@discussions.microsoft.com> wrote in message
news:11**********************************@microsof t.com...
I am creating a booking system in ASP.Net with VB and a MSSQL backend.

I am having problems knowing where to begin with a particular part of the
system. Bookings can only be made in weekly multiples from Saturday to
Saturday.

The only way I can think of to do it is by manually adding the weeks into
a
table in the DB, but this will obviously mean that I will have to
routinely
update this table.

Is there any way to cope with this problem programmatically? The most
suitable solution would be to write a chunk of code that the site
administrator can run every once in a while to automatically populate a
table
with the weeks (this table will need to store a Week ID and a Start
Date)....

Any ideas!!!!???? I'm stuck!!

Nov 19 '05 #2
the first request for a weekid can create the row if its not there. you can
use datapart to validate that the start date is correct (or calc the start
from any given date).

-- bruce (sqlwork.com)
"Aaran76" <Aa*****@discussions.microsoft.com> wrote in message
news:11**********************************@microsof t.com...
I am creating a booking system in ASP.Net with VB and a MSSQL backend.

I am having problems knowing where to begin with a particular part of the
system. Bookings can only be made in weekly multiples from Saturday to
Saturday.

The only way I can think of to do it is by manually adding the weeks into
a
table in the DB, but this will obviously mean that I will have to
routinely
update this table.

Is there any way to cope with this problem programmatically? The most
suitable solution would be to write a chunk of code that the site
administrator can run every once in a while to automatically populate a
table
with the weeks (this table will need to store a Week ID and a Start
Date)....

Any ideas!!!!???? I'm stuck!!

Nov 19 '05 #3

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

Similar topics

3
by: David | last post by:
Hi Group, i am trying to use the DatePart function on my SQL2000 database. I have a table called visitors with a field called DateTimeEntrance which is filled everytime a visitor enters the site....
3
by: Chumley the Walrus | last post by:
I'm trying to use DatePart and Datediff functions to show the formatted m/dd/yyyy display for the dates of Monday and Friday of the current week. I want it to display as: Our Weekly Schedule...
3
by: S. van Beek | last post by:
Dear reader, With DatePart() you can subtract the year or the week from a date field with: DatePart("yyyy";) for the year
2
by: troddy | last post by:
I am using the DatePart funtion in a query to extract the day, month and year in separate fields in a query. The function works fine but I am only getting a number for the month even if the field...
2
by: le0 | last post by:
Hello guys, Is there anything wrong with my code (see below) bcoz when 10p-6a shift my browser returns the error cannot be a zero-length string. Im wondering why, bcoz the 2 other shift works...
9
by: Cliff | last post by:
I want to use the Datepart function to determine the week number based on my company's fiscal calendar which starts Nov. 1. I have tried the following and they all produce #ERROR# . ...
7
by: tasmontique | last post by:
I have an access table that outputs to excel using a query . However what I am trying to do is under the arrival date column specify a criteria based on the Datepart function that only displays...
10
by: Mika M | last post by:
Hi! I'm converting some methods of VB-class into C#-class for another project. It's quite easy, but when converting method which returns last week number of the entered year I got problems. The...
3
by: grabit | last post by:
Hi Peoples I am having probs with the datepart function with a query.What i want is to get all listings made in any month in any year ie May 2007 i have 2 drop down boxes to select the listedmonth...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.