Comment ne retourner que la date d'un fichier SQL Server DateTime datatype

Mots clés : sqlsql-servertsqldatedatetimesql

meilleur 5 Réponses Comment ne retourner que la date d'un fichier SQL Server DateTime datatype

vote vote

99

SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, @your_date)) 
SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())) 
2008-09-22 00:00:00.000 
vote vote

83

SELECT CONVERT(date, GETDATE()) 
vote vote

78

select cast(getdate() as date) 
vote vote

69

set showplan_text on GO  
  |--Compute Scalar(DEFINE:([Expr1004]=CONVERT(varchar(30),[TEST].[dbo].[DatesTable].[MyDate],101)))        |--Table Scan(OBJECT:([TEST].[dbo].[DatesTable])) 
  |--Compute Scalar(DEFINE:([Expr1004]=dateadd(day,(0),CONVERT_IMPLICIT(datetime,datediff(day,'1900-01-01 00:00:00.000',CONVERT_IMPLICIT(datetime,[TEST].[dbo].[DatesTable].[MyDate],0)),0))))        |--Table Scan(OBJECT:([TEST].[dbo].[DatesTable])) 
vote vote

57

SELECT CONVERT(VARCHAR(10),GETDATE(),111) 

Questions similaires