9 Replies Latest reply on Sep 6, 2006 12:17 AM by luciewong

    send reminder 30 days before expire date?

    luciewong Level 1
      Hi, I hope someone can help me with that.

      I am getting in an "expireDate" from a Database.
      It can be for ex. "5/21/2007" . This date is a String.

      30 days before that expireDate is reached, I want to send a reminder to the client, like
      "your membership is going to expire".

      How can I find the date ! 30 days before it expires?

      Best regards,
      Luciewong
        • 1. Re: send reminder 30 days before expire date?
          2m Level 2
          it shouldn't be hard to create a new date object based on that string, you can then calculate the Date 30 days earlier and then compare it to the current date, if those match send you message.

          The problem I see is how to be sure that the user visits the site at exactly thet date, or at all?

          And as you need server side scripting anyhow, why not do it all in e. g. PHP instead of Flash?
          • 2. Re: send reminder 30 days before expire date?
            luciewong Level 1
            Hi, 2m,
            thanks for the reply.
            You are right, what happens if he enters on day 29 before expire date, - nothing will happen.

            So what I need actually - how many days are there from today until "expireDate"?< and this must be a number.
            Then I could say,
            if this number <= 30/ send my first warning.
            if this number <= 15/ send my second warning.

            But no idea, how can I get this number from today until "5/21/2007"
            Will try to find it somewhere. Maybe NSurveour has written something before or do you know?.
            Thank you
            Luciewong
            • 3. send reminder 30 days before expire date?
              fdarweesh
              why dont you try this

              var expdate:Date = new Date(2006, 8, 1);
              var current:Date = new Date();
              if ((current-expdate)/(1000*3600*24)) < -30
              //minus mean current date is less that expiredate
              {

              // put your action here

              }


              note:

              it is better to do this on the server side not on the client side


              regards

              Firas Darweesh
              • 4. Re: send reminder 30 days before expire date?
                luciewong Level 1
                Hi Firas,

                this looks not bad, but...
                the problem is, I get a String in like "4/20/2007"

                - how do I convert this String, so I can put it in here>
                var expdate:Date = new Date(2006, 8, 1); <<<<

                Thank you
                Luciewong
                • 5. Re: send reminder 30 days before expire date?
                  abeall Level 3
                  var str = "4/20/2007";
                  var a = str.split('/');
                  var myDate = new Date(Number(a[2]),Number(a[0]),Number(a[1]));
                  trace(myDate);
                  • 6. Re: send reminder 30 days before expire date?
                    luciewong Level 1
                    Thank you abeall,
                    this is also good, it returns now
                    Sun May 20 00.00.00 GMT+0800 2007

                    but.... now from current date to this date -
                    can I find out, how many days?? so I can reach my target to send my reminder 30 days before expire date??

                    regards
                    Lucie
                    • 7. Re: send reminder 30 days before expire date?
                      luciewong Level 1
                      Hi, to All,
                      unfortunately still I could not get the solution for my problem.

                      I have 2 strings coming in from a Database.
                      todayDate = "9/7/2006";
                      expireDate = "4/20/2007";
                      // now, I could find the difference in months with the code below>

                      aDate = todayDate;
                      bDate = expireDate;
                      //
                      TimeUsed.text = monthsBetween(toDate(aDate),toDate(bDate));//<<will be "7"
                      //
                      function toDate(str){
                      var d_arr = str.split('/');
                      return new Date(d_arr[2],d_arr[0],d_arr[1]);
                      //xxx
                      };
                      //
                      function monthsBetween(d1,d2){
                      var d_date = new Date(d1.valueOf());
                      var t_date = new Date(d2.valueOf());
                      var m = -1;
                      //xxx
                      while(d_date<=t_date){
                      //xxx
                      d_date.setMonth(d_date.getMonth()+1);
                      m++;
                      }
                      return m;
                      };
                      //xxx
                      //This will return me the difference between the 2 date strings in months, great, but can I get the d a y s between??

                      Thank you for your help.
                      Luciewong

                      • 8. send reminder 30 days before expire date?
                        Craig Grummitt Level 3
                        so stuck on your question i think you've missed that its already been answered! so i've compiled it into one place for you:
                        • 9. Re: send reminder 30 days before expire date?
                          luciewong Level 1
                          Hi Craig,
                          thank you very much, yes this did the job.
                          Now I have 226, the difference in days, great,
                          how stupid I am.
                          Thanks to all.

                          Luciewong