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
How to get every Monday out of a Date
I need some help to understand a certain line in a code. The code takes the turnovers of every Monday in the year 2010 and at the last line in summarizes all the turnovers to one.
Here is the code:
SELECT
CASE
WHEN GROUPING (DATUM) = 1…

user3084375
- 1
- 1
0
votes
1 answer
Count how many days someone has spent being a certain age in a certain time period
Hi I am using SQL DB2 and have a study window of 2005-01-01 to 2012-12-31, where various people have lived at an address(s) for varying amounts of time e.g.
Person Date_birth Address Start End
1 1973-06-01 312a…

brucezepplin
- 9,202
- 26
- 76
- 129
0
votes
1 answer
SQL unable to find DateDiff
I am currently creating SQl where I need to find DateDiff between two Dates.
My sample Table
Sno ItemId LineItemId CurrentEndDate RStartDate REndDate
1 101 541 10/12/2013 11/12/2013 10/12/2014
2 101 542 …

RajGan
- 801
- 3
- 13
- 28
0
votes
3 answers
Convert a DATEDIFF result to a string, to concatenate another string to it
I have a DATEDIFF result (in minutes) that i have divided by 1440 to count as days, I wish to add 'Hours' to the end of it but cant figure out how to turn the result into a string first.
DATEDIFF(mi,z.entryDate, GETDATE()) / 1440
this returns 11,…

Matt
- 343
- 2
- 4
- 17
0
votes
3 answers
php date() diff() How to get a date with zeros?
That get
i use code:
$then = new DateTime(date('Y-m-d H:i:s', $seconds_end));
$now = new DateTime(date('Y-m-d H:i:s', time()));
$diff = $then->diff($now);
But in var_dump($diff); i see:
object(DateInterval)#4 (8) {
…
user2881809
0
votes
0 answers
Datediff in minute in SQL
I am using following SQL query to find difference between two datetime fields which is calculate night time shift,
For example
today work time is evening 190957 til next date morning 071152 so the between time in fab minute is 628, but out fab…

Caulson Chua
- 29
- 2
- 9
0
votes
2 answers
Changing int to Time from a DateDiff
I have 3 times which I am putting onto a bar graph but I cant work out how to change the AvgUserSegmentTime to a Time format (00:00:00.00). Right now I'm getting Fastest = 00:00:00.01 Slowest = 00:00:24:22.22 and Avg = 61 which means the avg on a…

Thomas James
- 57
- 1
- 7
0
votes
1 answer
Crystal Reports if then, variables and dates
I need to create a crystal formula to look for a specific number in a record, if that number exist then create a date/time variable. Look for a second record with a different specific number and create a second date/time var. Then calculate a date…

user3037403
- 1
- 1
0
votes
1 answer
SQL days since DATEDIFF()
I'm trying to count the days since a post was made. SQL saves the date and time in the table pins in the column time. The format is 2013-11-20 10:36:01.
I have read up on how to do this on http://www.w3schools.com/sql/func_date_format.asp
and have…

Dalían
- 222
- 3
- 4
- 14
0
votes
1 answer
Querying SQL Database in php - Datediff?
I am building a sales dashboard and have run into a small problem which I am reasonably sure has a simple solution, but I can't quite get there.
So I have a SQL database built in SQL Server 2008. In terms of this database, I have no issues drilling…
user2995389
0
votes
1 answer
pdo mysql timestamp filter being ignored
I'm trying to select records from a table created in the last 24 hours using the function below. I don't understand why it is returning all records rather than just last 24 hours worth (created > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 24…

Barry Hamilton
- 943
- 3
- 15
- 35
0
votes
2 answers
php DateTime diff consider only Y-m-d format
In mysql db I've a timestamp field (dateexp) defined in my t1 table.
with a query I consider only format Y-m-d of timestamp to find records. Use curdate() instead of now()
SELECT * FROM t1 WHERE dateexp < currdate()
I would like to do the same…

Paolo Rossi
- 2,490
- 9
- 43
- 70
0
votes
2 answers
Datediff needed to be used for multiple rows of order activities
In SQL Server (TSQL) I need to find the date difference between a selection of order activities:
tblOrderActivity
OrderID ActivityID ActivityDate
1 1 4/16/2007 8:34:00 AM
1 2 4/16/2007 9:22:00 AM
2 1 …

Jeff Chambers
- 33
- 1
- 5
0
votes
1 answer
Insert a small cap after every date difference
I'm using a loop to the information from my database and I want to get the difference between the dates within this loop. I can show you how it looks like at the moment (the SQL query with the loop):
$get_photos = "SELECT * FROM photos ORDER BY…

Airikr
- 6,258
- 15
- 59
- 110
0
votes
2 answers
Finding Difference between two dates in Java
I'm using two JFormattedTextFields in Java for Date in my JFrame. I formatted them in format (DD/MM/YYYY).
How can i find difference between them in days?

Rahul Sharma
- 63
- 3
- 13