Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 DataTypes Question

Author  Topic 

Dasman
Yak Posting Veteran

79 Posts

Posted - 2011-06-28 : 11:39:53
Hello All,

So I have two datetime columns. Now I use a function to subtract two datetimes through the DATEDIFF function and get minutes. What datatype is that stored as?

Also just in general is there any help page on understanding datatypes, converting them to one another and what are the datatypes that help SQL move the fastest? My research deals mostly with datetimes so when u subtract two datetimes - what datatype is it? does it matter if I chose days, minutes, seconds, hours?

Thanks so much!

Dasman

==========================
Pain is Weakness Leaving the Body.

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-06-28 : 11:50:48
"What datatype is that stored as?"
DateDiff -- INT

"Also just in general is there any help page on understanding datatypes, converting them to one another..."
Cast and Convert
Go to Top of Page

Dasman
Yak Posting Veteran

79 Posts

Posted - 2011-06-28 : 11:57:47
Hey Russell,

Just to check - INT cannot store decimal values? Like say if my answer is 7.1333 what will int show?

What about 8.99? or 7.5?

Thanks,
Dasman

==========================
Pain is Weakness Leaving the Body.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-06-28 : 12:14:42
You can answer it by yourself.
Just do:

select convert(int,7.1333)

and you will see the result


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-06-29 : 03:54:14
Whenever you have a doubt do the following

select datediff(minute,getdate(),getdate()+1) as diff into #t

exec tempdb..sp_help '#t'

You will know what the datatype of the column is

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -