Questions tagged [datediff]

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.

1599 questions
0
votes
3 answers

DATEDIFF - How many days until Sunday

In SQL Server, trying to write a age-off report for inventory purposes. Each week, the inventory system marks thousands of rows for deletion. This takes place on Sundays @ 06:00:00 as part of weekly SQL DB purge schedule. Using (yyyy-mm-dd…
Doctorj77
  • 115
  • 2
  • 2
  • 11
0
votes
1 answer

How to find time different with php

I am trying to find time differences between two times. This is the code I have: $ddtcounter1="2014-03-06 20:20:30"; $ddtcounter2="2014-03-07 21:20:30"; $today = new DateTime($ddtcounter2); $pastDate = $today->diff(new…
morha13
  • 1,847
  • 3
  • 21
  • 42
0
votes
1 answer

Get re leaving employee's from table

This is my query I gave from month and to month for retrieve re leaving employee within that months select ED.EmpName, ED.EmpNo, OP.Dateofjoining, ED.deactivedate, DATEDIFF(MM,OP.Dateofjoining,ED.deactivedate) as Totalmonth from EmployeeDetails ED…
0
votes
2 answers

SQL Query DATEDIFF date time fields result in minutes

Can anyone tell me how to write the SQL Query to calculate the time difference between 2 columns that are stored as DATETIME columns and get the result in minutes... For example: Table structure ID, start-time, end-time I want to do a select on a…
0
votes
1 answer

Number of days between dates?

Dipping my toe into the world of reporting. I'm using Report Builder 3.0 and what I'm trying to do seems really easy, but I can't get it to work... I've got 2 datetime2 columns StartDate and EndDate and I want I'm trying to do is work out how many…
denimknight
  • 301
  • 2
  • 9
  • 22
0
votes
3 answers

MySQL get longest gap without activity

I have this table CREATE TABLE staff ( `id` int(11) NOT NULL AUTO_INCREMENT, `firstname` varchar(32), `surname` varchar(32), `dateEnrollment` date, `dateCompletion` date, PRIMARY KEY (`id`) ); INSERT INTO staff (`firstname`, `surname`,…
0
votes
1 answer

Problems with difftime &plyr

I have the following data frame called workfile: head(workfile) times users signal log 14 2014-01-13 00:00:16 00250902DC7D true ON 28 2014-01-13 00:00:47 00250902DC7D true ON 42 2014-01-13…
antonio
  • 77
  • 10
0
votes
2 answers

Date difference based on yyyy/mm/dd AM/PM in SQL

I am working with an equipment reservation system and need to calculate days that the equipment is being rented for so I can multiply it by the total cost per day of each reservation, then total the cost for all reservations in the query. The…
0
votes
1 answer

Using Datediff to find range values

How can I code the bellow condition in VBScript? >= 0 [Red] Ex.: {0,1,2,3,4...} Between -1 and -7 [Yellow] Ex.: {-1,-2,-3,-4,-5,-6,-7} ONLY Greater or equal than -8 [Green] Ex.: {-8,-9,-10,-11...} I have the following code, the Mydate is a valid…
Khrys
  • 2,670
  • 9
  • 49
  • 82
0
votes
1 answer

T-SQL DateDiff between the times but 1 datecolumn is 1900

I have a column that pulls in two dates, 1 of the dates has the correct date and time so I can easily compare the number of minutes between this date and GetDate() but some values have the date 01/01/1900 and then the time i need to use. How can I…
user3219693
  • 201
  • 3
  • 20
0
votes
2 answers

SQL Server 2008: DateDiff() of Min()/ Max() not working

Could you help me out with the following query? My goal: For each day and for each employee select minimum datetime and the maximum datetime and get the time difference in minutes My query : SELECT PersonalId, Name, LastName, Min(TmsPrick)…
User999999
  • 2,500
  • 7
  • 37
  • 63
0
votes
4 answers

SQL Find Age using DateDiff

Fields || Data ID || V465 DOB || 1946-09-05 DATE_OF_DEATH || 1974-05-11 I am using this SQL but I am getting an error. select DATEDIFF("YYYY",'DOB','DATE_OF_DEATH') where ID= 'V465' Its SQL SERVER Management Studio…
Sick Series
  • 163
  • 1
  • 6
  • 14
0
votes
1 answer

Clients with no invoices created in last 6 weeks, MySQL

I am having a hard time listing all the clients for which no invoice has been created in the last 6 weeks.Two tables are involved, client and invoice. My current query looks like this: select MAX(invoice.created_date) 'Last Invoice Date',…
Erind Pepi
  • 25
  • 4
0
votes
1 answer

MySQL date difference check within a trigger

Within a trigger before I insert some data into a table, I would want it to check, whether the difference of dates of events I am entering is greater than or equal to 1 day. There can only be one event in one club taking place each day. Sample…
Kamil Gosciminski
  • 16,547
  • 8
  • 49
  • 72
0
votes
1 answer

What's the method for converting time from ms to days?

today = Time.now => 2014-01-12 22:24:39 -0500 future = Time.parse("01-03-2014") => 2014-03-01 00:00:00 -0500 "%2.f" % ((future - today)/60/60/24) => 47 How else can I get 47 days without having to do /60/60/24 ?
MrPizzaFace
  • 7,807
  • 15
  • 79
  • 123