Search
 
SCRIPT & CODE EXAMPLE
 

SQL

datediff in sql server

SELECT DATEDIFF(dd, '2017/08/25', '2011/08/25') AS DateDiff
--result
-2192
Comment

datediff in sql

DECLARE 
    @start_dt DATETIME2= '2019-12-31 23:59:59.9999999', 
    @end_dt DATETIME2= '2020-01-01 00:00:00.0000000';

SELECT 
    DATEDIFF(year, @start_dt, @end_dt) diff_in_year, 
    DATEDIFF(quarter, @start_dt, @end_dt) diff_in_quarter, 
    DATEDIFF(month, @start_dt, @end_dt) diff_in_month, 
    DATEDIFF(dayofyear, @start_dt, @end_dt) diff_in_dayofyear, 
    DATEDIFF(day, @start_dt, @end_dt) diff_in_day, 
    DATEDIFF(week, @start_dt, @end_dt) diff_in_week, 
    DATEDIFF(hour, @start_dt, @end_dt) diff_in_hour, 
    DATEDIFF(minute, @start_dt, @end_dt) diff_in_minute, 
    DATEDIFF(second, @start_dt, @end_dt) diff_in_second, 
    DATEDIFF(millisecond, @start_dt, @end_dt) diff_in_millisecond;
Code language: SQL (Structured Query Language) (sql)
Comment

PREVIOUS NEXT
Code Example
Sql :: sql query to list all tables in a database sql server 
Sql :: Get the Db column names from a SqlDataReader 
Sql :: mysql update with subquery 
Sql :: select sequence oracle 
Sql :: mysql change password 
Sql :: sql get last inserted row 
Sql :: add column text sql after column 
Sql :: Check user permissions on postgres database 
Sql :: nested if in mysql 
Sql :: sql stored procedure with output parameters 
Sql :: select into temp table 
Sql :: select new table sql 
Sql :: create index mysql cli 
Sql :: show table postgres command 
Sql :: sql foreign key 
Sql :: postgresql resolv duplicate value violates unique constraint 
Sql :: python postgresQL select table 
Sql :: difference between super key and candidate key 
Sql :: mysql delete duplicate rows but keep one 
Sql :: mysql local password denied 
Sql :: oracle apex charging debug 
Sql :: desc in sql 
Sql :: declarative base sqlalchemy 
Sql :: python sqlite3 update 
Sql :: sql update insert and delete 
Sql :: sql select case when 
Sql :: between sql 
Sql :: python uuid sqlalchemy 
Sql :: create date sql 
Sql :: mssql datetime to date 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =