Results 1 to 7 of 7

Thread: Recurring Date

  1. #1
    Join Date
    Dec 2004
    Posts
    5

    Exclamation Unanswered: Recurring Date

    Here's my problem:

    I have a date that is entered into the field, 12/17/2004. My client wants the site set up so that when after the date is entered, it automatically updates itself every week. So the date represents an event, and he wants to update the event date automatically instead of having a user login and update the date manually. So 12.17/2004 shoudl turn into 12/24/2004, and then 12/31/2004 and so forth.

    One brilliant guy told me that if you entered a start date of and an end date then some how that might me be a little easier.

    Any thoughts good people?

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    Create a job in SQL Server Enterprise manager that runs the following query once a week:

    UPDATE <FIELD> = GETDATE() WHERE Variable = parameter

  3. #3
    Join Date
    Dec 2004
    Posts
    5
    Where do I go in MS SQL to create a new "job"?

    Quote Originally Posted by Thrasymachus
    Create a job in SQL Server Enterprise manager that runs the following query once a week:

    UPDATE <FIELD> = GETDATE() WHERE Variable = parameter

  4. #4
    Join Date
    Dec 2004
    Location
    California, USA
    Posts
    93
    Easiest is via Enterprise Manager - Under the Server goto Management - SQL Server Agent - Jobs.
    Whoever imagines himself a favorite with God holds others in contempt. - Robert Green Ingersoll, lawyer and orator (1833-1899)

  5. #5
    Join Date
    Dec 2004
    Posts
    5
    I still need help with the sql statement. The name of my table is events and the field where the date is inserted is called date. Should it be:

    update events set date = getdate()

    The previous reply said I should use this:
    UPDATE <FIELD> = GETDATE() WHERE Variable = parameter

    but I can't figure our what to do with the where clause. What do I need the where clause for?

    Quote Originally Posted by Chopin
    Easiest is via Enterprise Manager - Under the Server goto Management - SQL Server Agent - Jobs.

  6. #6
    Join Date
    Dec 2004
    Posts
    5

    i need help writing the sql statement

    I still need help with the sql statement. The name of my table is events and the field where the date is inserted is called date. Should it be:

    update events set date = getdate()

    The previous reply said I should use this:
    UPDATE <FIELD> = GETDATE() WHERE Variable = parameter

    but I can't figure our what to do with the where clause. What do I need the where clause for?

    Quote Originally Posted by Chopin
    Easiest is via Enterprise Manager - Under the Server goto Management - SQL Server Agent - Jobs.

  7. #7
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Well, you don't want to update it to GETDATE, anyway, because that will just set it to the current datetime. If you want to increment all the dates that have expired by one week, use this:

    Update YourTable
    Set Date = dateadd(d, 7, Date)
    where Date < getdate()

    You can run this job every evening.

    ...but this is a goofy requirement. I'd bet if you told us why you want to do this and how it is going to be used, someone here could come up with a more robust solution.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

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