Date-difference will give difference in the number of days, months, years etc. between any two calendar dates. Not defined by ISO/ANSI SQL, but several vendors have similar implementations.
Questions tagged [datediff]
1599 questions
0
votes
2 answers
SQL: Returning Columns of multiple tables and DATEDIFF in minutes
Attempting to retrieve columns from 3 different tables, with the TurnTime's being DATEDIFF's from a 4th table
CustomerName, OrderTypeName, LoanNumber, TurnTime1, TurnTime2,TurnTime3, TurnTime4
Tables:
tblCustomer, tblOrderType, tblOrder,…

Brody
- 11
- 2
0
votes
1 answer
using sql to select records based on date differences
I manage a system that records changes in it's stock item's price and quantity.
The table would look like this:
STOCK(ID, DATE, QUANTITY, PRICE)
(1, 2013.01.07 00:00, 9, 6)
(1, 2013.01.02 00:00, 9, 5)
(1, 2013.01.01 00:00, 10, 5)
(2, 2013.01.07…

user2365532
- 3
- 1
0
votes
3 answers
How do i find the difference in 2 dates (in days) when using m-d-Y format?
I need something like this
$today = date("m-d-Y");
$otherdate = "05-03-2013";
//Some math here
//echo the difference between the two dates in days
I've tried using strtotime but it doesn't work correctly and usually says something like the…

Douglas Mckee
- 29
- 2
0
votes
2 answers
MySQL; LEFT OUTER joining on DATEDIFF with indexes taking 300+ seconds (but only the first time)
MySQL's built in cache really makes this question moot for most of the day, but the very first time the following query is run, the performance is terrible: Taking over 300 seconds the first time whereas subsequent querying can complete in…

veeTrain
- 2,915
- 2
- 26
- 43
0
votes
3 answers
Trouble calculating time difference in PHP when doing action
$timeFromMysql = strtotime($createdtime);
$currenTime = SPRequest::now();;
if ($diff = abs( strtotime( $timeFromMysql ) - strtotime( $currenTime ) > 30*24*60*60) {
ACTION
}
I just wondering if I am doing this right. it seems the action is…

Simpel
- 103
- 1
- 1
- 7
0
votes
1 answer
How to sum using datediff in SSRS
My goal is to get the following result in my *.rdl report from my SSRS expressions in visual studio 2008. The DueDate and InvoiceAmt are bound fields (fields!duedate.Value and fields!valuehome_1). The "NotDueYet" and "0-30 Days" are aliases with…

Ken Mahone
- 11
- 1
- 3
0
votes
0 answers
Days difference from html5 form date
how can obtain de difference of two dates in days from an html5 form with date picker ?
i have tried with something like this, that didn't work yet: it showed NaN (Not a Number)
0
votes
1 answer
MySQL timediff — is it a bug?
This must return 1440 minutes and is working fine:
select abs(round((TIME_TO_SEC(TIMEDIFF('2013-03-13 10:00',
'2013-03-14 10:00'))/60),2)) ;
(2) same function date changed to 2 years days this returns…

balu
- 81
- 3
0
votes
3 answers
DATEDIFF with cutoff time
I'm working on a Room Scheduling application. We have this Room Check Out Rule that we need follow. All
room check out should be 12:00 PM. If the check out date is after 12.00 PM it will be considered additional 1 day.
Below is my T-SQL code that…

user2059064
- 153
- 3
- 7
- 17
0
votes
3 answers
Calculating difference between days * price per day = value PHP
I'm currently working on a little form that allows people to book a stay at a hostel. Basicly, I get them to pick two dates. (Day of arrival & day of departure) Then I want to calculate the difference between those dates in days, and finally I want…

Jefferson
- 993
- 2
- 16
- 35
0
votes
3 answers
subtract two dates and show result in date formate
i m tried hard to get the date in the date formate after subtracting
two dates but not getting the correct result ,and the result is 1970-01-07 05:00:00 but i require the result 2013-02-07 12:02:00
$start_date =strtotime('2013-02-13…

Shahbaz
- 3,433
- 1
- 26
- 43
0
votes
1 answer
How can I calculate difference of year and month in Python?
I have a script that get the date from datetime, and the date from whois service:
import time
from datetime import datetime
import whois
#date
url='testurl.com'
now = datetime.now()
date1 = datetime.strftime(nowstr,'%Y-%m')
#whois
domain =…

Alex A
- 107
- 2
- 11
0
votes
2 answers
SQL Calculate Difference Between Current and Last Value By Timestamp Column
I am looking to calculate the difference between the current & last Value organised by the timestamp column?
My table is organised as follows:
MeterID(PK,FK,int.not null), ActualTimeStamp(smalldatetime,not null), Value(float,null)
Meter ID …

Aaron
- 39
- 1
- 6
0
votes
1 answer
PHP - Date / Time difference using only working hours
I am trying to create a function that will work out the time difference between 2 times but only includes WORKING HOURS.
This is for a project which tracks the time it takes for a job to be completed.
Working hours are 9am - 5pm, Monday -…

Clarkey
- 698
- 3
- 11
- 28
0
votes
1 answer
date datediff without weekend how can it work with 2 different years
I have also a problem with datediff without week end, if you can help me:
i try to find days between two dates and it's give the right result when the dates are in same year, but when the date change the year it goes wrong:
my code is:
convert…

sraja
- 1