Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 123»»»

What will happen? Expand / Collapse
Author
Message
Posted Tuesday, August 31, 2010 10:50 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, February 21, 2011 9:29 AM
Points: 9, Visits: 14
Comments posted to this topic are about the item What will happen?
Post #978490
Posted Tuesday, August 31, 2010 10:53 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, June 30, 2014 2:51 AM
Points: 2,003, Visits: 369
DECLARE @a INT
DECLARE @b DATETIME

SET @b = @a


implicit conversion from int to datetime works fine
Post #978491
Posted Wednesday, September 1, 2010 12:02 AM
UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Sunday, June 29, 2014 11:26 PM
Points: 1,481, Visits: 1,960
Post #978503
Posted Wednesday, September 1, 2010 12:38 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 11:47 PM
Points: 1,094, Visits: 1,353
Good Question. Thanks

Thanks
Post #978513
Posted Wednesday, September 1, 2010 12:50 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 12:26 PM
Points: 21,631, Visits: 15,286
thanks for the question



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #978518
Posted Wednesday, September 1, 2010 1:37 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 1:16 AM
Points: 1,748, Visits: 474
Thanks for the question!
Post #978548
Posted Wednesday, September 1, 2010 2:45 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, August 11, 2014 1:23 AM
Points: 117, Visits: 463
@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
Post #978561
Posted Wednesday, September 1, 2010 2:58 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Friday, July 5, 2013 11:51 PM
Points: 488, Visits: 336
ziangij (8/31/2010)
DECLARE @a INT
DECLARE @b DATETIME

SET @b = @a


implicit conversion from int to datetime works fine


Is this dependent on the sql server version?


Saurabh Dwivedy
___________________________________________________________

My Blog: http://tinyurl.com/dwivedys

For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537

Be Happy!
Post #978565
Posted Wednesday, September 1, 2010 6:47 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 3:24 PM
Points: 1,393, Visits: 478
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
Post #978706
Posted Wednesday, September 1, 2010 7:00 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 7:45 AM
Points: 2,039, Visits: 2,039
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
Post #978714
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse