|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, February 21, 2011 9:29 AM
Points: 9,
Visits: 14
|
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 2:53 AM
Points: 1,529,
Visits: 359
|
|
DECLARE @a INT DECLARE @b DATETIME
SET @b = @a
implicit conversion from int to datetime works fine
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 3:15 AM
Points: 1,476,
Visits: 1,943
|
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Yesterday @ 7:11 AM
Points: 877,
Visits: 1,159
|
|
Good Question. Thanks
Thanks
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Monday, May 20, 2013 1:07 PM
Points: 18,733,
Visits: 12,332
|
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 2:10 AM
Points: 1,239,
Visits: 346
|
|
Thanks for the question!
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Thursday, April 25, 2013 7:59 AM
Points: 103,
Visits: 410
|
|
@ziangij please try the code below. I think this is what the auhtor wanted to convey. However one thing I would like to point out that Datetime is 8byte and Int is 4byte. DECLARE @a INT DECLARE @b DATETIME set @a= getdate() SET @b = @a
Thanks, Tushar
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Thursday, January 05, 2012 2:05 AM
Points: 488,
Visits: 335
|
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Today @ 1:51 PM
Points: 1,329,
Visits: 423
|
|
This is how we get the date for the current day without time element
DECLARE @a INT DECLARE @b DATETIME set @b = GETDATE()-.5 SET @a = CONVERT(INT,@b) SELECT CONVERT(DATETIME, @a), @b
the -.5 is half a day because CONVERT(INT,@b) rounds
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 11:21 AM
Points: 1,500,
Visits: 1,512
|
|
mbova407 (9/1/2010) This is how we get the date for the current day without time element
DECLARE @a INT DECLARE @b DATETIME set @b = GETDATE()-.5 SET @a = CONVERT(INT,@b) SELECT CONVERT(DATETIME, @a), @b
the -.5 is half a day because CONVERT(INT,@b) rounds
If I run the code above I get: (No column name) | (No column name) 2010-09-01 00:00:00.000 | 2010-08-31 20:54:59.743
Looks like the time is still there but just 0.
Here's another way to get the current date without the time:
Select CONVERT(varChar(10), getDate(), 101); This returns: 09/01/2010
|
|
|
|