How to display a past time in days, hours and minutes?



How to display a past time in days, hours and minutes?..

Answer / Vijayraj Singh Baghel

To display a past time in SQL Server in days, hours and minutes, you can use DATEDIFF function. Here's an example:n`DECLARE @pastDate DATETIME = '2022-01-01'; SELECT DATEDIFF(dd, @pastDate, GETDATE()) AS Days,n DATEDIFF(hh, @pastDate, GETDATE()) / 24.0 AS Hours,n DATEDIFF(mi, @pastDate, GETDATE()) / (60 * 24) AS Minutes;`

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

What is the impact on other user sessions when creating indexes?

1 Answers  


What is surrogate key? : sql server analysis services, ssas

1 Answers  


What is reference section?

1 Answers  


How can you tell if a database object is invalid?

1 Answers   MCN Solutions,


What is meant by datasource?

1 Answers  


query processing

1 Answers  


What are the different types of sql server replication? : sql server replication

1 Answers  


A successfully created SSIS package in SQL Server 2005 runs fine in MS BIDS and Integration Services. But gives error when run through an SQL-Job. What are the possible reasons?

2 Answers   Sapient,


What is attribute relationships, why we need it? : sql server analysis services, ssas

1 Answers  


What is mscorsvw.exe - process - microsoft .net framework ngen?

1 Answers  


How many columns can exist together per table?

1 Answers   Cap Gemini,


What is the use of custom fields in report?

1 Answers  


Categories