Reputation: 277
how do I convert or cast a date in integer like yyymmdd to a datetime format so that and picks today's date , getdate() ?
I have tried these:
cast(DateIDas ,getdate()) cast(DateID,as datetime,getdate()
Upvotes: 0
Views: 1217
Reputation: 1413
Try this...
SELECT CONVERT(VARCHAR(10), getdate(), 112)
with variable
DECLARE @myDate DATE= '10/15/2014'
SELECT CONVERT(VARCHAR(10), @myDate, 112)
convert date(int) into datetime
DECLARE @myIntDate int= 20141015;
select MyDate = cast(cast(@myIntDate as char(8)) as datetime);
Upvotes: 1