datepart function

G

Guest

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!!
 
K

Kevin Spencer

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.
 
B

Bruce Barker

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top