Working With Time (dateDiff)
I'm having trouble working out the best way of calculating the time difference between two times on the same day. The example I have found des return the hours (in this case 8) but forgets the minutes. I am looking to return the hour & the minute but i've had a look at the dateDiff format and this doesn't seem possible ?
---------------------------------
time1 = "09:15"
time2 = "17:30"
hours = datediff("h",time1,time2) ' in hours
response.write(hours)
----------------------------------
View Replies
ADVERTISEMENT
I'm pulling a time value in the format "24HH:MM:SS" into a variable "Time1" but I neeed to create two offsets to that time as other variables. One three hours previous to "Time1" and one that is one hour after "Time1". Is there an easy way to add/subtract times to generate these other variables? I've worked a little with datediff, but never with manipulating times as such.
View Replies
View Related
I need some code to work out 7 days from the current date. I can hard code it but thought i would ask in here to see if someone has some code already.
View Replies
View Related
I am trying to work out the length of time that a page was opened till it reached another page, I amusing the script below Code:
View Replies
View Related
I am trying to replicate the Ebay Time Left on Auction.
1 Day, 1 hour, 12 minutes.
I would like to calculate this from the current time and date. How do I get
this result?
View Replies
View Related
Code:
Set rs = objconn.Execute ("SELECT * FROM members WHERE UserID =" & UserID )
iMinute = DateDiff("n", Now, rs("LastLogin")) 'Find amount of minutes...
iHour = DateDiff("h", Now, rs("LastLogin")) 'Find the amount of hours...
iDay = DateDiff("d", Now, rs("LastLogin")) 'Find the amount of days...
iMonth = DateDiff("m", Now, rs("LastLogin")) 'Find the amount of months...
response.Write(iMinute)
response.End()
is this correct? is doesn't look right what is brings back
View Replies
View Related
I face that problems
07/01/2003 06/30/2006 ---------> it should be 3
01/01/2003 02/28/2005 --------->could i get 2 years and 2 months
01/01/2003 03/01/2005 --------->could i get 2 years and 2 months and 1
day
View Replies
View Related
I am trying to replicate the Ebay Time Left on Auction. 1 Day, 1 hour, 12 minutes. I would like to calculate this from the current time and date. How do I get this result?
View Replies
View Related
I'm creating a Help Desk Call Track System... one of the fields we want to store is the length of time the call was "Open." When the call is logged, the Now function is used to pull the date in vbGeneralDate format. When the call is closed, Now is again used to pull the date in the same format.
Our current system uses hours to track calls
To give an example of what is making it to the database...
BeginDate = 2/5/2004 2:19:40 PM
EndDate = 2/5/2004 2:20:09 PM
Then I do this calculation...
Duration = DateDiff("h",BeginDate,EndDate)
The value stored in the database is...
Duration = 14
I'm assuming that it is reading back to 12:00 AM and counting the hours up till 2:00 PM. I'd like to be able to do fractions of hours (displayed in decimals).
View Replies
View Related
Can someone tell me why this date range can't function for date diff?
Code : datediff("w","6/10/2005","6/16/2005", vbSunday)
It return 0 instead of the correct value is 1 !!
Why?
I have try others day, it goes well but just this date range ....
View Replies
View Related
i have an if else satemement and this part here checks to see if today's date is eactly two weeks away from the expirydate in the database.... however nothing happens so when i did a resopopnse.write i got the datediff difference of 223 ??!! how do i solve this problem?
ElseIf DateDiff("d", FormatMediumDate(created), FormatMediumDate(objRS("ExpiryDate"))) = 14 Then
Response.Write "<div class='Change7'><font color='#FF0000'><b>"&FormatMediumDate(objRS("ExpiryDate"))&"</b</font></div>"
View Replies
View Related
taken from hafiz's thread. i've got problem to check the user's last ectivity which is more than 20 minutes.which one is correct??? this one:Code:
'check if current user's last activity was more than 20 minutes ago
If Abs(DateDiff("n", rs1("LastActivity"), Now()))> 10 Then
or this one Code:
If Abs(DateDiff("n", Now(), rs1("LastActivity")))> 10 Then
the LastActivity datatype is a Text?
View Replies
View Related
i have a problem with datediff(), it works fine when i run it on my system iis but online its giving unexpected results. for eg.
checkin=30/04/2005
checkout=01/05/2005
nights=datediff("D",checkin,checkout)
result should be "1"
but its giving "-115"
pls. give me a clue to solve this.
View Replies
View Related
i have an if else satemement and this part here checks to see if today's date is eactly two weeks away from the expirydate in the database.... however nothing happens so when i did a resopopnse.write i got the datediff difference of 223 ??!! how do i solve this problem?
PHP Code:
ElseIf DateDiff("d", FormatMediumDate(created), FormatMediumDate(objRS("ExpiryDate"))) = 14 Then Response.Write "<div class='Change7'><font color='#FF0000'><b>"&FormatMediumDate(objRS("ExpiryDate"))&"</b</font></div>"
View Replies
View Related
I have a calendar that I am trying to make users fill out a form if their entry is inside the current week. Is there a datediff code that anyone knows of that can do this?
View Replies
View Related
I want to be able to pull all the records from a table "Accounts" which are more than 7 days old. The attribute "DateCreated" stores the date the account was created.
I've tried "SELECT * FROM Accounts WHERE DateDiff('dd', DateCreated, Now()) > 7" but this is coming up with an error (I'm using MS Access db by the way)
Any ideas or help?
View Replies
View Related
i need select statements that counts records from my access database where the time difference is worked out between two fields (datein;dateclosed). Less than 24 hours, >3 days, >5 days, >10 days, >15 days, >30 days, >60 days, >90 days
i am not sure how to construct the statement. If i can just get one, i can hopefully do the rest.
i have now:
strSQL2 = "SELECT Count(*) As Total FROM ptqr WHERE DateDiff('d','" & datein_now & "','" & dateclosed &"')< 1 "
but i get an error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC Microsoft Access 97 Driver] Data type mismatch in criteria expression.
/asp/ford_tsb/pscs/reports/charts/Chart5.asp, line 40
View Replies
View Related
I was going to use the DateDiff function for something, so I looked up the syntax real quick at w3schools. Here's what they have:
document.write(Date & "<br />")
document.write(DateDiff("m",Date,"12/31/2002") & "<br />")
document.write(DateDiff("d",Date,"12/31/2002") & "<br />")
document.write(DateDiff("n",Date,"12/31/2002"))
Output:1/14/2002
11
351
505440
I put the same code into a simple test document to verify, except for mine has Response.Write. All my numbers came out negative. If I reverse their positions, I get positive numbers. Is the example above wrong or is there something going on with my PC?
View Replies
View Related
I have a datediff comparision value on my form. Since one of the dates inside the datediff is: now(), I'd like to know if there's a way to show the result dinamically (without reloading the page..). I can't see how to do it from server side...It's possible to use js to fill the field or reload only the field value? detail: I'll need to submit the current diftime value along the other input values on my form at the end of process.
View Replies
View Related
i am facing error as
Microsoft VBScript runtime error '800a000d'
Type mismatch: '[string: ""]'
/pages/result.asp, line 12
Code:
View Replies
View Related
I just need to know the DateDiff function for what I need to do...
I will store the date of the database record in a variable called 'sDate' what now? (Also, the format is xx/xx/xx 2:4:56 PM/AM)
View Replies
View Related
I would like to display the difference between the logging time
[Session("start"] and the current time [now]. In hours minutes and seconds,
I have tried a couple of things but all I see is gobbledy gook.
View Replies
View Related
I have a website that I subscribe to that allows me to track tasks. I have an extra computer with a big monitor that i want to always display the task list. the problem is after so many hours I get logged out.
I need to need to reload that sign in url every few hours Code:
View Replies
View Related
there i was just windering how do i compare a date/time vlaue in sql server agaisnt the computers' date/time.
for example, if computer date/time is two months or 2 weeks before the database date/time do something
View Replies
View Related
Currently working on a ASP for a friend, which requires the date and
time on it. It pulls in entries from an Access Database with dates and
times in the format of:
"Fri Oct 17 18:02:46 2003"
However my date and time on the ASP page is displayed as:
"Friday, October 17, 2003 18:02:46"
using the script:
"<%Session.LCID = 1033%>
<%=FormatDateTime(Date(), vbLongDate)%>
<%Session.LCID = 2057%>
<%=time()%>"
Anyone know how to change this script, fully or partly to produce the
date and time on the format that's in the access database i.e. "Fri Oct 17
18:02:46 2003" Code:
View Replies
View Related
I am working on a database that collects information about incidents. One of the fields that people enter is the time of the incident. I am trying to convert that string that people enter into a OdbcType.Time and I am at a lost.
View Replies
View Related
How will we convert the system date & time to other timezone for eg: Eastern Time zone using ASP?
View Replies
View Related
When the Form is submitted I use the Date() and Time() functions to put the date and time into the Body part of the e-mail. The time reported is three hours earlier than the time at which the Form is actually submitted.
I understand these functions are evaluated on the server so the server must be in a time zone three hours earlier than where I am . Is there any way I can get the local time at the location where the user is actually located. ?
View Replies
View Related
Any some tools or sample codes drop down asp script execute time and
database connection time ?
View Replies
View Related
I'm trying to do a very simple code that converts the server time into a time zone of your choice.
<%
dim h 'Current Hour
dim i ' Time Zone Increase - add or subtract hours
dim r 'Result Here
h = Hour(Now)
i = + 2
r = h + i
%>
but obvisouly i'm having trouble with the time zone convert.
View Replies
View Related
I am trying to compare the NOW time with a "deadline" time. Please help. Just not sure why this is not working. I need to be able to say IF IT'S BEFORE 9:30 TODAY, IT'S OKAY TO ADD SOMETHING. IF IT'S AFTER 9:30 TODAY, YOU MUST ADD IT TOMORROW.
CODE:
nowtime=now()
deadlinetime=formatdatetime(now(),2) + " 8:30:00 AM"
response.write "NOW: " & nowtime & "<BR>"
response.write "Deadline: " & deadlinetime & "<BR>"
if nowtime<deadlinetime then response.write "can send out today" end if
if nowtime>deadlinetime then response.write "must send out tomorrow" end
if
RESULTS:
NOW: 1/18/2007 8:51:43 AM
Deadline: 1/18/2007 8:30:00 AM
can send out today
As you can see, NOW is GREATER THAN Deadline, so it should must send out tomorrow.
View Replies
View Related
i want to calculate the total time between to dates and time.
Example: Total time elapsed from date 1 time 1 to date 2 time 2.
27/09/2004 11:00 - 28/09/2004 10:30
The user enters a record and then later comes back and closes it. I need to know the time it took from when they entered the record until the time it was closed.
View Replies
View Related
I just installed PWS on 2 machines (XP & 98).
The problem is that I can run the ASP files in the wwwroot folder when I use http://localhost from my browser or RUN (and that's for the default.asp). But the asp files do not work when I call them from a hyperlink in an HTML file.
View Replies
View Related