SXI Forum

A place to collect usefull tips, tricks and implementation strategies.

You are not logged in.

#1 02-09-2021 20:15:31

StephanB
Member
Registered: 21-11-2018
Posts: 39

MSSQL - DATEPART() function to get the integer value of datetime

The DATEPART() function returns a specified part of a datetime, this function returns the result as an integer value.
Example will give you only the data entries with the date of 2021-01-01:

SELECT [Flag],
       [Epoc],
       [Date],
       [Action],
       [EID],
       [UID] 
FROM MyTable 
WHERE DATEPART(year,[Date]) = '2021' and  DATEPART(month,[Date]) = '01' and DATEPART(day,[Date]) = '01'

Last edited by StephanB (02-09-2021 20:18:29)

Offline

Board footer

Powered by FluxBB