How to calculate the expired date when the topupAmount and topupdate are given

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • teenagelcruise
    New Member
    • Aug 2007
    • 18

    How to calculate the expired date when the topupAmount and topupdate are given

    Hi,

    I have a question,i need to do a task which is when client enter the topupdate and topupamount,the expected expired date will appear on the table,can anyone help me since i have spend 2 weeks to do this.i had try dateAdd function but still cannot. Here are my sample coding

    if Request.QuerySt ring("S_MobileN o") <> EMPTY then
    recordSet("Mobi leNo") = Request.QuerySt ring("S_MobileN o")
    end if
    if Request.QuerySt ring("S_Service Type") <> EMPTY then
    recordSet("Serv iceType") = Request.QuerySt ring("S_SeviceT ype")

    end if
    if Request.QuerySt ring("S_State") <> EMPTY then
    recordSet("Stat e") = Request.QuerySt ring("S_State")
    end if
    if Request.QuerySt ring("S_Locatio n") <> EMPTY then
    recordSet("Desc ription") = Request.QuerySt ring("S_Locatio n")
    end if
    if Request.QuerySt ring("S_TopupDa te") <> EMPTY then
    if IsDate(Request. QueryString("S_ TopupDate")) then
    DateStr = Day(Request.Que ryString("S_Top upDate")) & "/" & Month(Request.Q ueryString("S_T opupDate")) & "/" & Year(Request.Qu eryString("S_To pupDate"))
    recordSet("Topu pDate") = DateStr
    end if
    end if
    if Request.QuerySt ring("S_TopupAm ount") <> EMPTY then
    if isnumeric(Reque st.QueryString( "S_TopupAmount" )) then
    recordSet("Topu pAmount") = Request.QuerySt ring("S_TopupAm ount")
    end if
    end if
    if Request.QuerySt ring("S_Expired Date") <> EMPTY then
    d_added=DateAdd ("d",TopupAmoun t,TopupDate) 'ExpiredDate = TopupDate + TopupAmount'
    document.write( "d_added")
    end if
    if Request.QuerySt ring("S_owner") <> EMPTY then
    recordSet("owne r") = Request.QuerySt ring("S_owner")
    end if
    if Request.QuerySt ring("S_remark" ) <> EMPTY then
    recordSet("rema rk") = Request.QuerySt ring("S_remark" )
    end if



    recordSet.Updat e
    connectionToDat abase.Close
    Set connectionToDat abase=Nothing

    Plz help Me!!Tq
  • ilearneditonline
    Recognized Expert New Member
    • Jul 2007
    • 130

    #2
    Originally posted by teenagelcruise
    [CODE=asp]
    if Request.QuerySt ring("S_TopupDa te") <> EMPTY then
    if IsDate(Request. QueryString("S_ TopupDate")) then
    DateStr = Day(Request.Que ryString("S_Top upDate")) & "/" & Month(Request.Q ueryString("S_T opupDate")) & "/" & Year[/CODE]
    You are returning a string from the QueryString depending how you send the S_TopupDate, it may not be a valid date. You could do [CODE=asp]Response.Write( IsDate(Request. QueryString("S_ TopupDate")) [/CODE]
    then you can verify if it is returning as a valid date. If you are passing something like 08212007, that will return false.

    Comment

    • teenagelcruise
      New Member
      • Aug 2007
      • 18

      #3
      thanx but i want to solve my problem regarding how to calculate expired date if the topup date and amount of the prepaid card is given..plz anyone can help??

      Comment

      • markrawlingson
        Recognized Expert Contributor
        • Aug 2007
        • 346

        #4
        Er, this sounds like you are trying to add a monetary value to a date - which won't work.

        What context is TopUpAmount? Is it a monetary value, an integer, or a date in itself?

        Comment

        • teenagelcruise
          New Member
          • Aug 2007
          • 18

          #5
          hi,
          topupamount is currency,when user topup his/her prepaid the expired date for the credit will be count by this system.

          tq and plz anyone help me!!!

          Comment

          • markrawlingson
            Recognized Expert Contributor
            • Aug 2007
            • 346

            #6
            Well then that's your first problem

            d_added=DateAdd ("d",TopupAmoun t,TopupDate)
            How do you hope to add a currency value to a date?

            You're basically saying : add $24 to September 2nd 2007

            Comment

            • teenagelcruise
              New Member
              • Aug 2007
              • 18

              #7
              but topupamount is the day because when you topup 30,the expired date will be increased to 30 days more.

              Comment

              Working...