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 stored procedure update if parameter is not null 
Sql :: mysql count characters in string 
Sql :: list table columns mysql 
Sql :: sql alter table order by 
Sql :: how to select random rows from a table 
Sql :: SQL Duplicates by Composite 
Sql :: charindex 
Sql :: postgresql check total storage 
Sql :: minus in sql 
Sql :: mysql count table rows 
Sql :: PL SQL VARRAY of records 
Sql :: declare table variable sql 
Sql :: mysql how to use FIND_IN_SET function in WHERE clause ? 
Sql :: all tables and views oracle 
Sql :: mysql not equal 
Sql :: image for MSSQL Windows Docker 
Sql :: reset keys in sql 
Sql :: there is no unique constraint matching given keys for referenced table 
Sql :: mysql find duplicate rows multiple columns 
Sql :: having count oracle two columns 
Sql :: mysql if statement 
Sql :: order by multiple columns 
Sql :: mysql workbench tutorial 
Sql :: remove last characters in mysql 
Sql :: reset postgres table index to next max value 
Sql :: call function in query sql server 
Sql :: sql view index 
Sql :: on sql table data exists 
Sql :: postgres date 
Sql :: dublicate row sql 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =