Sometimes we need to have only date from datetime field in sql.
There are number of ways to accomplish that:
Suppose we take current date
select getdate()
now to take only date from current date excluding time, we do as follows in various ways:
select DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))
select convert(varchar,getdate(),101)
select convert(char(8),getdate(),1)
select cast(cast(getdate() as int) as datetime)
select cast(convert(varchar,getdate(),110) as datetime)
Tuesday, June 2, 2009
Get Only Date from Datetime in Sql
at
11:34 PM
·
Labels: Sql Server
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment