datepart function

Discussion in 'ASP .Net' started by =?Utf-8?B?QWFyYW43Ng==?=, Nov 3, 2005.

  1. 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!!
    =?Utf-8?B?QWFyYW43Ng==?=, Nov 3, 2005
    #1
    1. Advertising

  2. 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:...
    >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!!
    Kevin Spencer, Nov 3, 2005
    #2
    1. Advertising

  3. =?Utf-8?B?QWFyYW43Ng==?=

    Bruce Barker Guest

    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:...
    >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!!
    Bruce Barker, Nov 3, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James Vanns
    Replies:
    7
    Views:
    7,010
    Evan Carew
    Jan 21, 2004
  2. David

    DatePart query

    David, Sep 16, 2003, in forum: ASP General
    Replies:
    3
    Views:
    167
    Tom B
    Sep 17, 2003
  3. Tipple
    Replies:
    2
    Views:
    118
    Tipple
    Oct 16, 2003
  4. Chumley the Walrus
    Replies:
    3
    Views:
    130
    Chumley the Walrus
    Aug 27, 2004
  5. le0

    DatePart

    le0, Aug 11, 2006, in forum: ASP General
    Replies:
    1
    Views:
    108
Loading...

Share This Page