i m using the getdate function to get the current date from the server . I want to get only the date (not the time part etc). I used the following code. It works but i dont think thats the best way of doing this. Any help would be appreciated.
--------------------------------------------------------
Declare @MyDate as smalldatetime,
@MyDay as varchar(2),
@MyMonth as varchar(2),
@MyYear as varchar(4)
select @MyDate = GETDATE()
select @MyDay = CAST (DATEPART(day , @MyDate) as varchar(2))
select @MyMonth = CAST (DATEPART(month , @MyDate) as varchar(2))
select @MyYear = CAST ( DATEPART(yyyy , @MyDate) as varchar(4))
select @MyDate = CAST ((@MyMonth + '/' + @MyDay + '/' + @MyYear) as smalldatetime)
select @MyDate
--------------------------------------------------------
Declare @MyDate as smalldatetime,
@MyDay as varchar(2),
@MyMonth as varchar(2),
@MyYear as varchar(4)
select @MyDate = GETDATE()
select @MyDay = CAST (DATEPART(day , @MyDate) as varchar(2))
select @MyMonth = CAST (DATEPART(month , @MyDate) as varchar(2))
select @MyYear = CAST ( DATEPART(yyyy , @MyDate) as varchar(4))
select @MyDate = CAST ((@MyMonth + '/' + @MyDay + '/' + @MyYear) as smalldatetime)
select @MyDate