SQL Problem With DateDiff (7 Days Old)
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
ADVERTISEMENT
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 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'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
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 built a asp website for my baby boy to let my family & friends to view notes and pictures about him and I was wondering if there was a code that I can use to automatically display the "years", "days" old he is based of his birthdate?
display Like this:
1-year 11-months old
View Replies
View Related
Code:
<%
If "DATE_SUB(CURDATE(),INTERVAL 30 DAY)" < rsTest("dat") then
response.write "It is within 30 days"
End if
Else
response.write ""
%>
I am trying to have it show something if the date in my database is within 30 days of the current date.
View Replies
View Related
the script below writes the next seven dates and their weekday names. it works a treat, until it gets within seven days of the end of a month. when that happens, the number of days shrinks and shrinks until the 1st of the next month, when it goes back to normal.
my question is - what needs to be changed here in order for it continue displaying dates into the next month? Code:
View Replies
View Related
I've set up a membership module which allows members to have a validity period of one year.
So if start date is = Date() [which is todays date]
Would the expiry date be Date() + 365 ?
View Replies
View Related
I've got a very simple database holding requests that users have submitted.Once we take care of the request we mark it shipped.There's a check box field in the database which holds this value.
I'd like to create a page that lists all shipped requests for the past 10 days.The SQL is giving me problems though.I'm not sure how to write this out.
View Replies
View Related
i want to add particular days of the week of past two months into a dropdown list according to current date at run time but i am unable to do so can anybody tell me how to do that.
View Replies
View Related
Does anyone know of a formula that I can use to work out the number of days in a month not including the weekends?
I know I could probably use a loop that checks each day and if it is a weekday it adds to a counter but I'm guessing that would make things run a tad slower and the way this system is running I wouldn't want to make it any slower.
View Replies
View Related
I need to display the count of days on the page where the start date is the result of the record set and the end date is the current date. So if the record set value was 3/04/2007 than the display on the page would be "3" ( with todays date: 3/07/2007 as the end date). I know I need to use datediff(d,???? ) you can see where I get lost.
View Replies
View Related
How can I check if today is Sunday or Saturday and put it into If EndIf condition.
View Replies
View Related
There maybe a easy solution but I just can't seem to find it. I've got a membership module that sets up a expiration date of one year since they joined. So I have a DB field called "membershipexpiry" which has the expiration date(). I'm doing up a backend to keep track of membership periods and want to display all memberships that would expire in 30 days. What would the right SQL statement be?
sql = "SELECT * FROM users WHERE membershipexpiry..........".
View Replies
View Related
I'm trying to find any examples or instruction on how to code some ASP that enables someone to search an Access db with a date field (mm/dd/yyyy) so many days back (to be specific, the user could select 7 days, 14 days, or 30 days from a pulldown menu) from the current date.
View Replies
View Related
Is there any way of working out a day of the week from a given date?
View Replies
View Related
How do I calculate In ASP how many working days are there until a particular date?
View Replies
View Related
I am wanting to create my own calendar asp module.Are there any functions in vbscript that return the number of days in a particular month depending on what year it is?
View Replies
View Related
I am trying to subtract days from a date but I didnt got it. how to do it?
View Replies
View Related