Skip to main content

All Questions

Tagged with
-1 votes
1 answer
50 views

Find first value with datediff larger than 1 week from table and join with initial table

I have two tables: dbo.HistPrices (Which has all Historic Prices for every PId and some non interesting metadata... etc. ) PId (non-unique) Price Pricedate ... 1 5 2022-11-03 2 3 2022-11-03 2 (more ...
NorrinRadd's user avatar
1 vote
1 answer
73 views

T-SQL : unwanted data conversion failing

I'm trying to group data into seconds. Currently, I use a T-SQL query to break down SQL data into minutes. SELECT TOP 200 DATEADD(MINUTE, (DATEDIFF(MINUTE, 0, TIMESTAMP) / @Value) * @Value, 0) '...
freakostudent's user avatar
0 votes
0 answers
38 views

T-SQL : set start of the week from named date and show week nr of the date

I have a code that traces a number of week of the date in a period that set by parameters CREATE TABLE #test ( job int, dateL datetime ) INSERT INTO #test VALUES (1, '2021-10-04'), (...
Ekaterina Chistyakova's user avatar
0 votes
1 answer
165 views

sql how many days one period contains in other given period

I need to calculate how many days one set period contains in another set period. I have table with create table #test ( ,project nvarchar(10), startProjectDate date, endProjectDate date) insert into #...
Ekaterina Chistyakova's user avatar
1 vote
3 answers
245 views

Getting the correct hour value with datediff

I'm trying to use the datediff function in SQL Server. I'm querying two datetime columns in the same table. I'm trying to get the results where I get hours and minutes in decimal points. As an example ...
R. Pen's user avatar
  • 19
3 votes
1 answer
955 views

SQL Calculating day away from birthday using their DOB

I have a question regarding finding birthdays according to the date they were born, sadly I haven't found an answer for this on this website. I want the set a number foreach date that has X days away ...
Kaede's user avatar
  • 308
0 votes
2 answers
116 views

Calculate difference in hours between two datetime values

I'm working on a query that deals with the details behind a series of electronic documents. Each document has a CreateDate and a CompletedDate, both of which are in datetime format. My goal is to ...
EJF's user avatar
  • 461
0 votes
1 answer
127 views

Conversion failed when converting date and/or time from character string with DateDiff

I have looked at probably every other question, tried every other answer and nothing has worked so I am going to throw out what I am trying to do and hope I can get some help. Here is what I am ...
KCone's user avatar
  • 31
0 votes
1 answer
206 views

Calculate elapsed time (DATEDIFF) while subtracting time for break and lunch periods

I have a table that looks like: job | start_time | end_time ---------------------------------------------------------- 1 | 2020-08-31 09:46:00.000 | 2020-08-31 12:37:00.000 2 | ...
jmarusiak's user avatar
  • 145
1 vote
1 answer
6k views

Arithmetic overflow error: Msg 8115, Level 16, State 2

I've got an issue with a stored procedure causing an: Arithmetic overflow error converting expression to data type int. The are two tables, the first pulls in data from an ODBC connection. The data ...
Martin's user avatar
  • 43
0 votes
3 answers
8k views

DATEDIFF between two dates to return timestamp

SOLVED CONCAT((DATEDIFF(Minute,START_DTTM,END_DTTM)/60),'h:', (DATEDIFF(Minute,START_DTTM,END_DTTM)%60) 'm') AS TotalTimeMissing Produces TotalTimeMissing: 5h:13m ________ I'm trying to ...
TornIntegral's user avatar
0 votes
1 answer
59 views

The DATEDIFF function return 2 row

I have the query that works properly and i get the following output : 9 1116 JOHN 0590056093 9106809105 3 A NULL D 9 1117 SARA 0015562451 9203410410 3 A ...
Reza Hatami's user avatar
1 vote
4 answers
806 views

What does the number mean in this statement: DATEDIFF(wk, 6, '2020-01-03');

The documentation states DATEDIFF(interval, date1, date2); I can't find any info on what a number means there.
Nowheels's user avatar
2 votes
2 answers
667 views

Is there a way to perform a DATEADD() with a range of increments in T-SQL?

Looking for a shortcut to getting a column with a range of dates +/- 3 days of a specific date. I haven't found an elegant shortcut. My premise maybe off, I haven't found a way to have a range of ...
DRT's user avatar
  • 103
2 votes
3 answers
255 views

DATEDIFF with variable seed

I have the following table The first column are transaction dates order by Date DESC. The second column is binary state for each transaction, could be either 0 or 1. The third column is the datediff ...
PoNti3's user avatar
  • 41

15 30 50 per page
1
2 3 4 5
9