Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2006
    Posts
    55

    Unanswered: date in a database

    dear experst:

    i have a web site and a calendar where a client can select a day week or a month to see some statistics, for the day i know how to do it. and i have also stored procedures. what i want is how to store the startday and end day in a variable when the client select a week or a month, so i can assign these variables to the stored procedure so the stored procedure can query the database and return the data for just the specific selected date.

    this problem is realy annoying me and i can not continue my work without solving it. any help will be more than appreciated.
    thanks
    Peace out
    Mr joka

  2. #2
    Join Date
    Oct 2004
    Location
    In cousin's house
    Posts
    303
    varname1 = startday
    varname2 = endday
    I'm here to learned something not to help you.

  3. #3
    Join Date
    Oct 2006
    Posts
    55
    thanks for your reply,
    what i want is how to know the start date and the end date when i user select a week or a month and how to calculate the value so when give it to the stored procedure it will know that is a week?
    thanks
    Peace out
    Mr joka

  4. #4
    Join Date
    Feb 2003
    Location
    India
    Posts
    216
    to get the Frist/Last day-of-the-week, Frist/Last day-of-the-month u can use the following queries. this assumes that Sunday is the first day of the week and Saturday is that last one. also the dates r calculated with respect to date variable.

    Code:
    declare @DtVar smalldatetime
    set @DtVar = '2007-03-22'  --- an example date
    select @DtVar+1-datepart(dw,@DtVar) as StartingDayOfTheWeek 
    select @DtVar+7-datepart(dw,@DtVar) as LastDayOfTheWeek
    select @DtVar+1 - datepart(dd,@DtVar) as FristDateOfTheMonth
    select dateadd(mm,1,@DtVar) - datepart(dd,@DtVar) as LastDateOfTheMonth

  5. #5
    Join Date
    Oct 2006
    Posts
    55
    thanks a lot for your answer, but what if i want monday be the first day of the week and sunday the last day of the week? what should i changed.
    thanks
    Peace out
    Mr joka

  6. #6
    Join Date
    Oct 2006
    Posts
    115
    dude, please play around with the number. when you got a solution for a problem, you shall learn to understand it and explore further. By asking, "what if i want Monday", you're asking the same question....

  7. #7
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Set @@datefirst 1
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  8. #8
    Join Date
    Oct 2004
    Location
    In cousin's house
    Posts
    303
    Quote Originally Posted by mrjoka
    thanks a lot for your answer, but what if i want monday be the first day of the week and sunday the last day of the week? what should i changed.
    thanks
    You can assign the days into an int array and pass to your stored procedure.
    I'm here to learned something not to help you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •