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

Compare datetime, only show time if Ymd are same

I have 2 values stored in a database. One is a startdate, the other an enddate. Now when the Year, month and date of the 2 are equal. I would like the enddate to only show the time. For example maandag 16 juni 14:06 tot maandag 16 juni 14:15 would…
user3481441
0
votes
9 answers

time difference of comma-delimited values

I have a requirement from my customer. Data pattern is below for Note Column :TT: 12:32,12:35 :TT: :TT: 05:17,05:30 :TT: :TT: 01:56,02:00 :TT: :TT: 01:00,01:12 :TT: I need to remove :TT: tag and subtract first value from last. for…
Nishant
  • 74
  • 2
  • 10
0
votes
3 answers

PHP Datediff days involved

I need to know how many days are involved in a date diff. \For example: diff($ende); echo $diff->format('%R'); echo $diff->days; ?> The…
0
votes
1 answer

Use DATEDIFF in a case

I got a problem with my request. I want to compare 2 dates, and if the number of days is inferior to 2, i want to display nothing. But if it's over, I want to display the days. I got my request but it failed when I try to compare the DATEDIFF to…
bl4ckb0ne
  • 1,097
  • 2
  • 15
  • 30
0
votes
2 answers

SQL get date of upcoming Friday

How do I get the date of upcoming/next Friday using SQL? If the current day is Friday, then return today's date. Thanks so much, any tips and advice appreciated!
viv_acious
  • 2,429
  • 9
  • 34
  • 55
0
votes
2 answers

Weeding out lengthy Durations

I only want to keep durations less than 10 minutes long. my current code is as follows: Duration = DateDiff(ss, TimeBegin, TimeEnd) TimeBegin and TimeEnd are in TIME format. Obviously Duration right now comes back as: 00:00:07 That's where I'm…
0
votes
2 answers

SQL Server rounding

The DateDiff = 23 so 23/30 is 0.77. I cannot get @Tenor to be 1, which is 0.77 rounded ... it keeps giving me 0 ... DECLARE @Tenor Decimal(18,6) SET @Tenor = ROUND(DATEDIFF(D,'2014-04-14','2014-05-07') / 30, 0) It works if I do this ...…
nanonerd
  • 1,964
  • 6
  • 23
  • 49
0
votes
1 answer

Converting DateDiff and Count expressions from Access SQL to MySQL

Please, can someone help me with this part of query? It's working fine in Microsoft Access but won't work in MySQL: DateDiff("m",[first_sent_date],[last_sent_date])+1 AS basetime_month, Count(tablename.id) AS cnt_all
LeBro
  • 1
  • 2
0
votes
1 answer

Timeline for activity using SQL Server

I have a table that logs when user enters and leaves a specific room during the course of a day using a swipe system. I am attempting to create a more visual based report based on the data stored in our SQL Server which is in the below…
user3615823
0
votes
5 answers

MySQL date difference between column3 of first row and column2 of second row

I searched for the above topic and only getting query in Oracle which uses certain keywords specific to oracle. +----------+------------+--------------------+ | Agent_id | valid_from | last_modified_date…
0
votes
1 answer

how to update a single column of a table with the value from the select statement that gives the date difference?

I want to update a column of a table with the value coming from the following query. SELECT DATEDIFF(days,'EndDate','StartDate') AS DiffDate. Can I do this in a single sql statement? Right now I have a table with columns(StartDate, EndDate,…
ZeeProgrammer
  • 195
  • 1
  • 13
0
votes
3 answers

How to check if a cell contains a date less than 6 months ago or if it containts text?

I have a column in Excel that contains a list of dates, say for example 02/09/13 and then in another column I have a formula to detect whether or not the date is 6 months older than today, and if it is, it should display "True" in this…
user2012630
  • 33
  • 1
  • 1
  • 6
0
votes
1 answer

Mysql Error Code : 1292 Incorrect datetime value : ''

I'm trying to insert a record to a table and I get the following error. Mysql Error Code : 1292 Incorrect datetime value : '' Mysql code snip-let is as follows INSERT INTO tbl_dashboard (avg_response) SELECT cast(ifnull(floor(avg(5 *…
user3447223
  • 31
  • 1
  • 3
0
votes
1 answer

DATEDIFF and NULL to find incomplete records in past N days

I'm using DATEDIFF and IS NULL to find records missing data for a certain number of days, For example, here I'm trying to find students who haven't taken any classes for 1095 days (3 years), if they're a registered student they can't go more than 3…
Chris
  • 71
  • 1
  • 1
  • 14
0
votes
1 answer

Wrong DateInterval with DateTime diff

I'm comparing two DateTime : //Get the current DateTime $date_now = new DateTime; var_dump($date_now); // 2014-03-10 19:04:29 // I need to subtract 12 hours (I'm using $date_past to fetch $db_date in a request) $date_past = $date_now->sub(new…
cocoggu
  • 401
  • 7
  • 18