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
Door log report datediff SQL Server 2008
I'm currently trying to produce data for when employees swipe in and out of various doors in the building. The data is saved in a table like -
Ideally id like to do a datediff for the minutes but am struggling to get it to work! anyone have any…

GPH
- 1,817
- 3
- 29
- 50
0
votes
1 answer
Fatal error when trying to format output using date_diff()
I'm using PHP 5.3.6 and when I try to run the code bellow I get the following error: "
Fatal error: Call to a member function format() on a non-object in ...".
function diferenta_date($data_inceput, $data_sfarsit){
$interval =…

Psyche
- 8,513
- 20
- 70
- 85
0
votes
3 answers
SQL Time Tracking Query
Data:
EmpNumber, TimeStamp, AreaName
10632, 2009-11-23 16:40:33.000, OUT_1
10632, 2009-11-23 16:39:03.000, IN_1
10632, 2009-11-23 16:38:56.000, IN_1
10632, 2009-11-23 15:31:51.000, OUT_1
10632, 2009-11-23…

Nick
- 43
- 6
0
votes
3 answers
Finding data closest to date?
I have a table
CREATE TABLE `symbol_details` (
`symbol_header_id` int(11) DEFAULT NULL,
`DATE` datetime DEFAULT NULL,
`ADJ_NAV` double DEFAULT NULL
)
with ~20,000,000 entries. Now I want to find the ADJ_NAV value closest to the end of the…

Martin Stein
- 306
- 3
- 11
0
votes
1 answer
MySQL Calculating sum over pairwise time differences of log file
i have a table in mysql to log user actions. Each row in the table corresponds to a user action, like login, logout etc.
The table looks like:
CREATE TABLE IF NOT EXISTS `user_activity_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11)…

Philipp
- 535
- 1
- 6
- 16
0
votes
1 answer
Selecting records younger then 2 minutes with DATEDIFF
I'm currently facing the following problem:
I want to select all the records from my database table LocationUpdates for a specific RFIDTagID AND a ScannedTime smaller then 2 min compared to the current time.
I am giving sql two parameters: 1.…

joostvandriel
- 107
- 1
- 1
- 7
0
votes
3 answers
Date differences between specific events in R
I've spent quite some time trying to calcule date differences between specific events. For example, I have the data set below, where t is the event datetime, e is the event ('A' or 'R') and id is an identifier.
t e id
2013-06-15…

MSS
- 53
- 1
- 8
0
votes
3 answers
How to find date difference excluding specific dates in array - PHP
I know how to calculate date difference using PHP like;
$newdate = "01-03-2013";
$olddate = "01-06-2013";
$date_diff = abs(strtotime($olddate)-strtotime($newdate)) / 86400;
echo $date_diff;
But suppose, if I have some dates in an array…

Alfred
- 21,058
- 61
- 167
- 249
0
votes
2 answers
Calculate Number of Occupied Days within a date period using MySQL and PHP
I have an apartment booking system and need to generate a report of number of occcupied days vs. unoccupied days within a date period on a property by property basis.
Bearing in mind within the chosen period that some bookings may start before…

Pandy Legend
- 1,102
- 3
- 15
- 29
0
votes
1 answer
How to get only last 6 months details in mysql
Can someone please help to get only last 6 months details. Tried with the answers which already mentioned in stackoverflow and mysql site. But didnt get the required output.
i tried with different combinations. but couldnt.
mysql> select date from…

divakar.scm
- 1,256
- 5
- 21
- 32
0
votes
2 answers
difftime between 2 columns and next.row within a variable
Trying to caulculate the difference in time between two two columns, however time 2 in 'difftime' is in the next.row
sample data:
structure(list(code = c(10888, 10888, 10888, 10888, 10888, 10888,
10889, 10889, 10889, 10889, 10889, 10889, 10890,…

Salmo salar
- 517
- 1
- 5
- 17
0
votes
2 answers
How do I create a Descriptive DateConverter in C#?
I have a DateConverter class that does all the basics. However, I want to add another type to it. I want to be able to have a 'Descriptive' type that returns the difference between the date and DateTime.Now formatted as a string.
IE: "seconds…

Pratt Hinds
- 225
- 1
- 3
- 13
0
votes
2 answers
SQL Statement to Select Day Interval
How can I get the range between a day dynamically for e.g. BETWEEN 23.05.2012 00:00 AND 23.05.2012 23:59 using MSSQL ? I got the first part;
WHERE
AND s.SCHEDULE_START_DATE BETWEEN dateadd(DAY, datediff(DAY, 0, getdate()), 0) AND FILL HERE

user1595357
- 289
- 1
- 4
- 11
0
votes
4 answers
How I calculate the difference of two date time
In my database i stored the date time in the following format. I want to get the difference between two samples in seconds. Is it any simple methods are available?
u'2013-05-20 05:09:06'
u'2013-05-20 05:10:06'

Hacker
- 133
- 5
- 16
0
votes
3 answers
How to get date difference with specific date format?
In my javascript code, I am able to only get the date as a string in this format:
Example: Mon May 28 11:20:46 EDT 2012.
Is there a way I can check if that date and the current date is >= than 1 week?

omega
- 40,311
- 81
- 251
- 474