Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Auto delete records

    I have an Events Calendar application that I want to automate a bit more. I
    need a way to have coldfusion delete a record if its "Expiry date" is past
    today's date.

    I have tried a conditional statement with limited success.

    Any ideas would be welcomed.

    Flog Guest

  2. Similar Questions and Discussions

    1. Why can't I delete these records?
      Hi all! When I do: SELECT COUNT(*) AS counter FROM table1 WHERE condition1 = 'A' AND condition2 IS NULL; it returns: +---------+ | counter...
    2. Delete records
      Hi, I have produced a page used a webthang tutorial ?Deleting Multiple Records Using Checkboxes by Rob Boyle? to delete records....
    3. Auto Add/Delete Bugs
      1) Position the Pen cursor over a pre-existing point of a selected path.The (infernal, despised) auto-delete Pen cursor appears. 2) Press Shift....
    4. HELP! Have large db. Need to delete all records.
      Client are 6 Server is 5.0 win2k server win2k& xpclients I have a large fmpro DB but cannot delete all the records to start new. I want to...
    5. Cannot delete records in Subform.
      I am unable to delete records within a subform (continuous) when I have it open in another form. If I open the subform on it's own, I am able to...
  3. #2

    Default Re: Auto delete records

    delete from thetable
    where expirydate <= current_date

    the current_date part is database specific. You should know what it is for
    your database. If this is not available in your datebase, you could always use
    the appropriate dateformat on the cf now function

    delete from thetable
    where expirydate <= #d 'datefomat(now(), "yyyy-mm-dd")'}#

    Originally posted by: Flog
    I have an Events Calendar application that I want to automate a bit more. I
    need a way to have coldfusion delete a record if its "Expiry date" is past
    today's date.

    I have tried a conditional statement with limited success.

    Any ideas would be welcomed.



    Dan Bracuk Guest

  4. #3

    Default Re: Auto delete records

    > delete a record if its "Expiry date" is past today's date
    As mentioned the exact syntax may depend on what type of database, column
    type, and/or connection you're using.

    Assuming "ExpiryDate" is a date/time column, if today is "10/29/2005"
    something like the attached query should work. It would delete all records with
    a date of 10/28/2005 or earlier (10/27/2005, 10/26/2005, etc...)

    NOTE: You might consider updating a "flag" column (is. "IsDeleted" instead of
    actually deleting the records. Especially if your events have related records
    in other tables.


    DELETE FROM yourTable
    WHERE ExpiryDate < #CreateODBCDate(now())#

    mxstu Guest

Posting Permissions

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

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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139