Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - DateDiff() problems
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

DateDiff() problems

 Post Reply Post Reply
Author
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Topic: DateDiff() problems
    Posted: 12 November 2003 at 2:28pm

Writting a simple script to show time a user has been online, and the time they have been inactive for.  Should produce something along the lines of:

Active for 7 mins
Inactive for 2 mins

But instead of this it produces:

Active for 7 mins
Inactive for 41760 mins

The code to update the last active field is:

strSQL = "UPDATE " & strDatabaseTablePre & "ActiveOperators SET lastActive = '" & now() & "' WHERE operatorID = " & lngOperatorID

And the code to display the report is:

Response.write("<font  color=""#008000""><B>Online</B></font>& lt;BR>Active for <B>" &  dateDiff("n",rsCommon2("cameOnline"),rsCommon2("lastActive") ) & "</B> mins<BR>")
Response.write("Inactive for
<B>" & dateDiff("n",now(),rsCommon2("lastActive")) & "</b> mins")

Example of a database record:

Lastactive: 11/12/2003 21:21:25
CameOnline: 11/12/2003 21:14:26

Any insight as to why its producing over 41,000 would be helpful!  Thanks

Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 12 November 2003 at 3:36pm
It should be dateDiff("n",rsCommon2("lastActive"),now())
Back to Top
Gullanian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 04 January 2002
Location: England
Status: Offline
Points: 4373
Post Options Post Options   Thanks (0) Thanks(0)   Quote Gullanian Quote  Post ReplyReply Direct Link To This Post Posted: 12 November 2003 at 3:43pm

Tried that, produces:

-41760

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 12 November 2003 at 4:36pm

considering that is almost a month off, i'd assume you aren't comparing what you think you are comparing

in that mess above.. break it up and spit out the individual dates, a la, and if you swap the order, the mins will just come out as negative, doing an absolutel function around it makes it not matter what order they are:

Response.Write "Date 1: " & Now() & "<br />"
Response.Write "Date 2: " & rsCommon2("lastActive") & "<br />"
Response.Write "Diff in Minutes: " & dateDiff("n",Now(),rsCommon2("lastActive")) & "<br />"

Contribute to the working anarchy we fondly call the Internet
Back to Top
Phat View Drop Down
Senior Member
Senior Member


Joined: 23 February 2003
Status: Offline
Points: 386
Post Options Post Options   Thanks (0) Thanks(0)   Quote Phat Quote  Post ReplyReply Direct Link To This Post Posted: 12 November 2003 at 5:17pm
If i run

DateDiff("n", "11/12/2003 21:14:26", "11/12/2003 21:21:25") then i get 7

I ran it in VB so not sure what it's it doing in ASP
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.