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
MS-SQL DATEDIFF GROUP BY To show hours for each jobcode
I have been thrown in over my head with some MS SQL work and am humbly requesting assistance. I am learning the basics but was given an assignment far above my skill level. I have been asked to provide a query that will show how many hours have been…

Mill3niumThr33
- 3
- 2
0
votes
0 answers
Crystal Enterprise 9: How to Calculate average for datediff
So I have this statement that calculates the time difference. It uses the previous mod_date minus the current mod_date. Now I would like to get the average of each users time interval, basically average of DateDiff.
Below is the SQL to get the time…

user2668214
- 21
- 7
0
votes
1 answer
Datediff issue - PHP,Mysql
So in my database i've got regdate (date type), but no matter what date it is, the code keeps returning 1.

Oudee
- 13
- 4
0
votes
1 answer
SQL Server 2008 time stamp subtraction to get total seconds (the time stamps are always changing)
I have little experience with SQL Server and need some help as our DBA is no longer with us and we are in the process of looking for a new one.
Background: We are using two columns in a table, customVariable2 and customVariable3. customVariable2 is…

user3892880
- 5
- 2
0
votes
1 answer
PHP thinks there are 2 months between Apr 1st and Jul1st
PHP 5.5.1.14:
$d1 = new DateTime("2014-04-01 00:00");
$d2 = new DateTime("2014-07-01 00:00");
$d3 = $d2->diff($d1);
echo $d3->m . " months, " . $d3->d . " days";
returns
2 months, 30 days
Is there a way to reliably get the intuitive result 3…

MBaas
- 7,248
- 6
- 44
- 61
0
votes
2 answers
Determine how long a phase takes, looking at current row and next row
I am working on a project for work, data logging type system. Currently using SQL Server 2008, can upgrade if needed. Currently we are taking 1 minute intervals of the equipment, we are gathering all sorts of information, I am only worried about…

user2644176
- 39
- 7
0
votes
2 answers
How stock a numeric value (diff of 2 date)
I've to calculate the différence between two Dates : TODAY() and DATE_DEB_VAC.
With Oracle, it's kinda easy : TODAY()-DATE_DEB_VAC -> give the number of day between those 2 date.
But I've to do it with in an ETL (GENIO). I've a column to stock it…

Drupal8ForTheWin
- 145
- 1
- 2
- 12
0
votes
1 answer
select datediff between fields or parameter
I have the following part within my select statement, which works when I write the dates, but when I send parameters it gives me an error.
This works:
SELECT (...unrelevant info), DATEDIFF(DAY, CASE WHEN Startdate > '14/6/2014' THEN Startdate ELSE…

user3821898
- 1
- 2
0
votes
1 answer
Look at last login and highlight if over a month ago
I have a gridview, with a column that shows the last login date of a member. I wish to highlight this date if they haven't logged in for over a month.
I have
If DateDiff(DateInterval.Month, Now(), e.Row.Cells(10)) Then
…

queenofrandom
- 101
- 3
0
votes
1 answer
Check if timeranges overlap
I need to check whether an entered time range overlaps with another time range
This thread PHP function to check time between the given range? gives a simple explanation on how to check if one date is with a range
I altered the second example…

PrimuS
- 2,505
- 6
- 33
- 66
0
votes
2 answers
SQL- Special DATEDIFF condition
I have a button which gets locked for previous month when we roll into new month.
Eg. if today's date is 04-06-2014, then the button will only be visible for this month only. For the previous month(May in this case), it will not be visible.
For that…

omkar patade
- 1,442
- 9
- 34
- 66
0
votes
3 answers
Script not working. Lint says Semicolon required
I am a beginner to Javascript Programming and have run into an error I cannot work out as I don't understand the code. Lint tells me there is a semi colon needed before the line var dString = "September, 25, 2015";. I did have this working and don't…

brettstix
- 3
- 4
0
votes
2 answers
Using DateDiff() in VB to find the difference between 2 dates in months and days
I need to find the difference between 2 dates in months and days in VB. Using DateDiff() function, I am not getting the desired result since DateDiff() subtracts the corresponding values only. For example:
DateDiff("m", '31/01/2012',…

Ritwik Dey
- 559
- 1
- 7
- 17
0
votes
1 answer
Update age category using age at event date
I'm trying to update my race results table with the user's age category, which is calculated by comparing age and gender with an age range in another table, something like this ..
update race_results.race_category = category.categoryname
where age…

csbchris
- 23
- 2
0
votes
2 answers
Create a variable to store a count for DATEDIFF greater than 3
This may be really simple and I'm probably overthinking it. I have to create a variable that stores the number of employees who have been employed with the company for more than 3 years.
Here's what I came up with since the original table does…

user3745347
- 15
- 1
- 4