Link to home
Start Free TrialLog in
Avatar of maqskywalker
maqskywalker

asked on

sql server 2008 datetime data types

hi experts,

I'm using sql server 2008 R2.

When I run this query:


DECLARE @datetime datetime = '2013-04-05 16:32:35';

DECLARE @datetime2 datetime2 = @datetime;
DECLARE @smalldatetime smalldatetime = @datetime;

SELECT @datetime2 AS '@datetime2', @datetime AS '@datetime', @smalldatetime AS '@smalldatetime';

I get the following result:

User generated image
What data type should I use to represent a date time value that looks like this?:

2013-04-05 16:32:35

I thought I was supposed to use smalldatetime data type.
But if you look at the image of my query above, when i use that data type the seconds are rounded up.

Am I missing something?
Why are the seconds rounded up in the smalldatetime datatype?

thanks.
ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial