date sql 2008 to datetime sql 2005
-
Thursday, December 06, 2012 6:46 AM
Im having a problem with sql 2005, it doesn't recognise 'date' which I already know but how would I use date time just to get the date in the following statement to work in sql2005. I have tried datetime and it doesnt work as I dont need datetime just date:
(cast(getdate()as date)as varchar(50))-This part is where the problem is happening if I use datetime
set @ScheduleTime =(cast(cast(getdate()as date)as varchar(50))+' '+convert(varchar(8),@ScheduleTime,108))
All Replies
-
Thursday, December 06, 2012 6:50 AM
Try the below:
Select Replace(CONVERT(Varchar(10),Getdate(),102),'.','-')
Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.
-
Thursday, December 06, 2012 6:50 AMAnswerer
SELECT CONVERT(VARCHAR(10),GETDATE(),121)
Best Regards,Uri Dimant SQL Server MVP, http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Blog: Large scale of database and data cleansing
Remote DBA Services: Improves MS SQL Database Performance
- Proposed As Answer by Latheesh NKMicrosoft Community Contributor Thursday, December 06, 2012 6:51 AM
- Marked As Answer by Iric WenModerator Monday, December 17, 2012 6:29 AM
-
Thursday, December 06, 2012 6:52 AM
Try the same in your code:
set @ScheduleTime =(CONVERT(VARCHAR(10),GETDATE(),121)+' '+convert(varchar(8),@ScheduleTime,108))
Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.
-
Thursday, December 06, 2012 6:52 AMHow would I incorporate that into my statement ?
-
Thursday, December 06, 2012 7:02 AM
Hi,
In SQL server 2005 you don't have any function to do so but you can take only date part as below.
SELECT CONVERT(VARCHAR(11),GETDATE(),105)
sarat chandra sahoo
- Marked As Answer by Iric WenModerator Monday, December 17, 2012 6:29 AM

