Subtracting Dates-Times

Results 1 to 2 of 2

Thread: Subtracting Dates-Times

  1. #1
    Join Date
    Dec 1969

    Default Subtracting Dates-Times

    I have an application where I&#039;m tracking the user&#039;s time logged into our site. I&#039;m setting the login and logout times to GetDate() in SQL Server which produces exactly the data I need like this:<BR>Login: 2/26/2003 9:18:19 PM <BR>Logout: 2/26/2003 9:20:59 PM<BR><BR>But I need to determine the difference between these entries to determine the length of time online. If I just a simple &#060;%=rs("Login")-rs("Logout")%&#062;, I get something like -1.15793981240131E-03. How should I go about this? Thanks.

  2. #2
    Join Date
    Dec 1969

    Default Look in the left panel of this page

    Find "VBScript Reference" and click on it<BR><BR>In the list of topics that appears, click on "Functions"<BR><BR>In the list of functions that appears, click on "DateDiff"<BR><BR>Read.<BR><BR>If you care about how come you got -1.157838E-03, you can read the ASPFAQs, category "Dates And Times" to learn more than you ever wanted to know about how DateTime values work, under the covers.<BR><BR>Incidentally, SQL Server *also* has DateDiff, so if you wanted to you could do the subtraction in your SQL query, instead of in VBScript. Again, read the docs.<BR><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