Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > datepart function

Reply
Thread Tools

datepart function

 
 
=?Utf-8?B?QWFyYW43Ng==?=
Guest
Posts: n/a
 
      11-03-2005
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!!
 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      11-03-2005
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" <> wrote in message
news:1159A5B9-97C5-47EF-997B-...
>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!!



 
Reply With Quote
 
 
 
 
Bruce Barker
Guest
Posts: n/a
 
      11-03-2005
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" <> wrote in message
news:1159A5B9-97C5-47EF-997B-...
>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!!



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DatePart le0 ASP General 1 08-11-2006 05:44 AM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM
DatePart function to display date for Monday and Friday of this week Chumley the Walrus ASP General 3 08-27-2004 06:45 PM
dateAdd and datePart return 13, 14, 15 instead of 1, 2, 3 Tipple ASP General 2 10-16-2003 03:57 PM
DatePart query David ASP General 3 09-17-2003 01:11 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57