www.webdeveloper.com
Results 1 to 5 of 5

Thread: get the Next Sunday

  1. #1
    Join Date
    Dec 2004
    Posts
    117

    get the Next Sunday

    Hello all,

    My table is structured as follows.

    SundayDate - Date
    Helper1 - VarChar(25)
    Helper2 - VarChar(25)
    Helper3 - VarChar(25)
    Helper4 - VarChar(25)
    Helper5 - VarChar(25)
    Helper6 - VarChar(25)

    I want to display the names of all the helpers that are that are associated with the next Sunday to come.

    For example, say I have 2 rows in my table:
    2008/01/13 John James Henry Albert Peter George
    2008/01/20 Ruth David Philip Simon Mikey Daniel

    Today is 2008/01/10, so I want to select John, James, Henry, Albert, Peter and George as the next Sunday after the today is 2008/01/13.

    I realise I need to get the date of the next Sunday (str_NextSundayDate). Once I have this date then I do something like :

    "SELECT * FROM table WHERE SundayDate = str_NextSundayDate"

    The bit I'm not sure of is how to work out what date the next Sunday will be.

    Can anyone advise?

    Thanks,

    John

  2. #2
    Join Date
    May 2007
    Posts
    63

    try this

    I have done something similar to find the next saturday, feel free to amend as needed

    $datecalc = strtotime(“Saturday”);
    $datesearch = date(“Y,m,d”,$datecalc);
    $conn = @mysql_connect(“localhost”,”********”,”********”);
    Squery = “SELECT * FROM table WHERE date = $searchdate”;

    regards
    Graham

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,918
    You can get next Sunday in this one-liner, if you like:
    PHP Code:
    $str_NextSundayDate date('Y-m-d'strtotime('next Sunday'));
    "SELECT * FROM table WHERE SundayDate = '$str_NextSundayDate'" 
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  4. #4
    Join Date
    Jan 2010
    Posts
    1
    Quote Originally Posted by john noble View Post
    Hello all,

    My table is structured as follows.

    SundayDate - Date
    Helper1 - VarChar(25)
    Helper2 - VarChar(25)
    Helper3 - VarChar(25)
    Helper4 - VarChar(25)
    Helper5 - VarChar(25)
    Helper6 - VarChar(25)

    I want to display the names of all the helpers that are that are associated with the next Sunday to come.

    For example, say I have 2 rows in my table:
    2008/01/13 John James Henry Albert Peter George
    2008/01/20 Ruth David Philip Simon Mikey Daniel

    Today is 2008/01/10, so I want to select John, James, Henry, Albert, Peter and George as the next Sunday after the today is 2008/01/13.

    I realise I need to get the date of the next Sunday (str_NextSundayDate). Once I have this date then I do something like :

    "SELECT * FROM table WHERE SundayDate = str_NextSundayDate"

    The bit I'm not sure of is how to work out what date the next Sunday will be.

    Can anyone advise?

    Thanks,

    John
    I had the same problem as you
    If you need a solution, try this
    http://www.joeylau.com/2010/01/09/church-code/
    Hope this helps

  5. #5
    Join Date
    Dec 2010
    Posts
    1

    For computing the coming Sunday

    Just test the following Block - You will get the next sunday

    BEGIN
    DECLARE @TEST_DATE DATETIME
    SET @TEST_DATE = '12/27/2010' --GETDATE()
    select @TEST_DATE as TODAY,
    datepart (dw, @TEST_DATE) as dayOfTheWeek,
    datename (dw, @TEST_DATE) as NameOfDay,
    DATEADD(DAY, (8-datepart (dw, @TEST_DATE)), @TEST_DATE) NEXT_SUNDAY
    END

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles