Results 1 to 2 of 2

Thread: Dates

  1. #1
    Join Date
    Dec 1969

    Default Dates

    one of of the points in ASP that I dont have much experience in, purposfully unfortunatly.. they scare me... shouldnt tho, but I need some help.<BR><BR>I save a date into a database, lets say its todays date, so what would be saved into the db is "8/4/2004" - this date is an account renewal date.<BR><BR>I want to be able to tell the user how many days they have until their account expires, the account term is 30 days. So how would I take that date and use it to make an expiration date that I could use in the DateDiff() function.<BR><BR>Hope this makes sense, thanks.<BR><BR>-Sab

  2. #2
    Join Date
    Dec 1969

    Default Many ways...

    &#060;%<BR>...<BR>&#039; do a query something like this:<BR>SQL = "SELECT customer, renewalDate FROM customers where custID = 771"<BR><BR>Set RS = someConnection.Execute( SQL )<BR><BR>renewBy = RS("renewalDate")<BR><BR>daysLeft = DateDiff("d", renewBy, Date() )<BR><BR>If daysLeft &#060; 0 Then<BR> Response.Write "Your account expired " & (-daysLeft) & " days ago."<BR>Else<BR> Response.Write "Your account will expire in " & daysLeft & " days."<BR>End If<BR>%&#062;<BR><BR>***********<BR><BR>If you want to find all the customers who will expire in the next 30 days, then you could do something like this:<BR><BR>&#060;%<BR>SQL = "SELECT * FROM customers WHERE renewalDate BETWEEN Date() AND (Date()+30)"<BR>Set RS = conn.Execute( SQL )<BR>Do Until RS.EOF<BR> ...<BR> RS.MoveNext<BR>Loop<BR>%&#062;<BR><BR>That syntax is for Access, where (like VBS) you can add and subtract days to/from a date without even using a function.<BR><BR>For SQL Server it would be easier to build the 30 days from now date in VBS:<BR><BR>SQL = "SELECT * FROM customers WHERE renewalDate BETWEEN &#039;" & Date() & "&#039; AND &#039;" & (Date()+30) & "&#039;"<BR>

Posting Permissions

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