datediff

SQL - Using datediff as a query is running?

Hi all, Its my first post and I'm really rusty on MSSQL so be gentle :-) I have a table in which I am trying to use datediff. I think it will be easiest if I post the query and results first select mh.agetime, mh.whatid from mailhistory mh inner join mail m on mh.mailid=m.myid where (mh.whatid=17 or mh.whatid=11 or mh.whatid=0) and...

MySQL query puzzle - finding what WOULD have been the most recent date

I've looked all over and haven't yet found an intelligent way to handle this, though I feel sure one is possible: One table of historical data has quarterly information: CREATE TABLE Quarterly ( unique_ID INT UNSIGNED NOT NULL, date_posted DATE NOT NULL, datasource TINYINT UNSIGNED NOT NULL, data FLOAT NOT NULL, PRIMARY KEY (unique_ID)...

T-SQL DateDiff - partition by "full hours ago", rather than "times minutes turned 00 since"

I have a table with timestamps, and I want to partition this table into hour-long intervals, starting at now and going backwards a couple of hours. I'm unable to get the results I need with the T-SQL DATEDIFF function, since it counts the number of times the minute hand passes 12 between the two dates - I want the number of times them mi...

Difference in days between two dates in Java?

Hi All, I've to find number of days between two dates: one, is from report and one, is current date. My snippet : int age=calculateDifference(agingDate, today); Here, calculateDifference method is a private method, agingDate and today are Date objects, just for your clarification. I've followed two articles from Java Forum Thread1 ...

Difference in Days between two Java dates?

Hi All, I want to get the difference between two Java Date objects. I've used Joda-Time library. But the problem is that I'm getting the Days greater difference than that of actual day difference. Here's my code snippet: DateFormat formatter = new SimpleDateFormat("mm/dd/yyyy"); Date someDate=new Date(); Date today = Calendar.getIn...

Undefined date_diff()

I'm trying to use date_diff(): $datetime1 = date_create('19.03.2010'); $datetime2 = date_create('22.04.2010'); $interval = date_diff($datetime1, $datetime2); echo $interval->format('%R%d days'); Its doesn't work for me, gives an error: Call to undefined function date_diff() How can I get it work? PHP 5.2 is used. Thanks. ...

SQL Datetime difference in days

I am trying to find how many days are between two dates. I have been attempting to use this: SET Days_Outstanding = DATEDIFF(day, CONVERT(datetime, LS_CHG_DTE_EQP, 1), CONVERT(datetime, Report_Date, 1)) However, this is not returning the number in days. It's returning a datetime in years that have nothing to do with my data set. ...

"Hour:Minute" difference from two "Hour:Minute" strings

Simple, eh? -sigh- A function. Two string arguments ( I guess it doesn't matter the type). Returning a string which is the time difference between the arguments. Think about it as a counter at your local CS internet-caffe. function time_diff($start, $stop) { ... return $diff; } echo "Your time playing CS: " . time_diff('19:37'...

Mysql: Calculate averge time between visits

This related to my other question. I have this table CREATE OR REPLACE TABLE hits (ip bigint, page VARCHAR(256), agent VARCHAR(1000), date datetime) and I want to calculate average time between googlebot visit for every page. ... WHERE agent like '%Googlebot%' group by page order by date Something ...

django: datediff sql queries?

I'm trying to do the equivalent of the following SQL in Django: SELECT * FROM applicant WHERE date_out - date_in >= 1 AND date_out - date_in <= 6 I can do this as a RAW sql query, but this is becoming frustrating in dealing with a RawQuerySet instead of a regular QuerySet object as I would like to be able to filter it later in the code...

SQL Server 2005: how to subtract 6 month

I have a date, suppose today date declare @d datetime set @d = '20101014' I need select @d - <six month> where is the real number of days that contains last six month, beginning from @d. ...

What is the recommended way of doing date arithmetics in Perl?

What is the recommended way of doing date arithmetics in Perl? Say for example that I want to know the date three days ago from today (where today = 2010-10-17 and today - 3 days = 2010-10-13). How would you do that in Perl? ...