adspace


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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain system functions or built-in functions? What are different types of system functions?

1067


How to convert numeric expression data types using the cast() function?

1151


If any stored procedure is encrypted, then can we see its definition in activity monitor?

1072


This question asked during interview, 2) At the end of each month, a new table is created for each bank that contains monthly metrics consolidated at the account level. The table naming convention is bankX_YYYYMM where X represents the numeric designation of the bank and YYYYMM indicates the 4 digit year and 2 digit month. The tables contain the following fields: name data type description account text account number registered boolean indicates whether the account is registered num_trans integer number of transactions made during the time period spend numeric(9,2) total spend during the time period a) Write a SQL query that will display the total number of transactions and total spend for "Bank1" during the 4th quarter of 2009. b) Write a SQL query that will display the total number of transactions and total spend at "Bank1" and "Bank2", broken out by registered vs. non-registered accounts, during January 2010 not sure what is correct answer and how to solve?

2568


What is sql or structured query language?

1228


How do I find the sql server version?

1103


What is in place upgrade in sql server?

1127


Why we use the openxml clause?

1080


Why and when do stored procedure recompile?

1064


What is the primary use of the model database?

1151


What are the properties of the transaction?

1074


When should you use an instead of trigger?

1054


What are the risks of storing a hibernate-managed object in a cache? How do you overcome the problems?

1200


How can I check that whether automatic statistic update is enabled or not?

1113


do you know how to configure db2 side of the application? : Sql server database administration

1125