When I select date in SQL it is returned as 2011-02-25 21:17:33.933
. But I need only the Date part, that is 2011-02-25
. How can I do this?
Its too late but following worked for me well
declare @vCurrentDate date=getutcdate()
select @vCurrentDate
When data type is date, hours would be truncated
In PLSQL you can use
to_char(SYSDATE,'dd/mm/yyyy')
In case if you need the time to be zeros like 2018-01-17 00:00:00.000
:
SELECT CONVERT(DATETIME, CONVERT(DATE, GETDATE()), 121)
Use is simple:
convert(date, Btch_Time)
Example below:
Table:
Efft_d Loan_I Loan_Purp_Type_C Orig_LTV Curr_LTV Schd_LTV Un_drwn_Bal_a Btch_Time Strm_I Btch_Ins_I
2014-05-31 200312500 HL03 NULL 1.0000 1.0000 1.0000 2014-06-17 11:10:57.330 1005 24851e0a-53983699-14b4-69109
Select * from helios.dbo.CBA_SRD_Loan where Loan_I in ('200312500') and convert(date, Btch_Time) = '2014-06-17'
For SQL Server 2008:
Convert(date, getdate())
Please refer to https://docs.microsoft.com/en-us/sql/t-sql/functions/getdate-transact-sql
CAST(
FLOOR(
CAST( GETDATE() AS FLOAT )
)
AS DATETIME
)
http://www.bennadel.com/blog/122-Getting-Only-the-Date-Part-of-a-Date-Time-Stamp-in-SQL-Server.htm