Sometime something so simple skips our mind. I never knew the difference between GETDATE and SYSDATETIME. I just ran simple query as following and realized the difference.
SELECT GETDATE() fn_GetDate, SYSDATETIME() fn_SysDateTime
In case of GETDATE the precision is till miliseconds and in case of SYSDATETIME the precision is till nanoseconds.

Now the questions is to you – did you know this? Be honest and please share your views. I already accepted that I did not know this in very first line.
This applies to SQL Server 2008 only.
Reference: Pinal Dave (http://www.SQLAuthority.com),












I didn’t know that and I’m kind of glad I haven’t run into a situation where it has mattered. This is good info to keep in mind in case I need this. How did you ever come across this?
Here is a guess, GETDATE is time off the DC oppose to the server time??? Your intro sentence is dead on.
I have enjoyed your blog for several years, thanks for your dedication!
I was unaware of the second function SYSDATETIME(). Thanks for posting. and again same question: I wonder how did you come across this?
Until SQL Server 2005, there was only one function, GETDATE() which returns a DATETIME value. A DATETIME value has precision upto 3 milliseconds.
SQL Server 2008 introduced a new data type DATETIME2 which gives precision upto 100 nanoseconds. But if you use the GETDATE() function and assign the result to a DATETIME2 value, you would loose the precision (nanoseconds).
So a new function was introduced which returns a DATETIME2 data type – having precision upto 100 nanoseconds.
The major difference is the return value TYPE of each function. One returns DATETIME and the other DATETIME2.
I did not know the difference between that sentences. Thanks for the info.
Regards.
Well, I knew that there is some differencies between functions and datetime data types as Jacob described above, but I wasn’t aware of this particular one.
I’ve took a habit of consulting MSDN every time I have doubts about something. For example I check built-in function parameters every time from MSDN. That is an easy way to find out things like this.
great Pinal!
I have never come across it. Thanks a lot for your contribution. I have learnt a lot from this blog.
Another question.
Pinal I want to appear in 70-432 exam,
I have ready two, three relevant books, one books designed by Syngress another by Microsoft for this certification.
Can you suggest a book which can help me pass the exam.
What about brain dumps for this exam.
Thank You.
Tahir
Hi,
i have searched about it and concluded Mr. Jacob Sebastian is correct.
But please any one mention the practical use of it
thanks,
biju
That is a good find pinal. I had Never come across this function. It would be good if someone points out the good use of this function. Most of time we use GetDate() function, I guess this function(SYSDATETIME) might be usefull if you have any time sensitive data…
Thanks
Harsha
As per BOL, the return type of SYSDATETIME is datetime2(7)
Also the query only works from version 2008 onwards only
Wow, did not know this. I wonder if there is ever a need or use for such precision in a stored procedure?
RESPECTED SIR,
I WANT TO BE A MEMBER OF YOUR COMMUNITY. PLEASE ALLOW ME TO JOIN AS IT WILL HELP IN MY STUDIES AS I AM A STUDENT OF MCA.
THANKS & REGARDS
KAMAL KANT.
I didn’t know either, just never used the second one, but any way, you can’t store in the database milliseconds with precision greater than .000 and with step less than .003
[...] 11, 2010 by pinaldave Yesterday I have written a very quick blog post on SQL SERVER – Difference Between GETDATE and SYSDATETIME and I got tremendous response for the same. I suggest you read that blog post before continuing [...]
hi, just never noticed it, but after trying it out where really it would be helpful, most of them that i use make use of the datetime data type and i can use getdate() with it and not sure where i can make use of the sysdatetime….
Really not used SYSDATETIME since the need for such precision is not there for my line of business. It is interesting to note that such precision is available.
[...] 12, 2010 by pinaldave Earlier I wrote blog post SQL SERVER – Difference Between GETDATE and SYSDATETIME which inspired me to write SQL SERVER – Difference Between DATETIME and DATETIME2. Now [...]
Thanks Pinal,
No i didn’t know this.
Thanks for Sharing.
Regards,
Nitin Sharma
Hi.
I knew :-)
I use sysdatetime when inserting rows in a log table. I need sysdatetime’s precision in that case.
Regards
Børre Dalhaug
Hi Pinal,
Thanks. Even i dont know the SYSDATETIME function in SQL.
Can you tell us more about the unknown SQL functions.
[...] SQL SERVER – Difference Between GETDATE and SYSDATETIME [...]
Hi pinal,
Thanks for the article…truly speaking even i never knew about this.
Hi Pinal,
Thanks. Even i dont know the SYSDATETIME function in SQL.
Can you tell us more about the unknown SQL functions.
[...] SQL SERVER – Difference Between GETDATE and SYSDATETIME [...]
The company I work for has updated to SS2008 but still wants to use SSMS 2005. Access 2003 and Excel 2003 is involved also. Datetime2 is the main issue
Acces and Excel convert the dates to text. and using native 2005 T-sql I have to convert the date to text to extract it. There are hundreds of reports that are affected. Fortunately 2008 this is still running in test.
Woud upgraning to Access and Excel 2010 and SSMS 2008 allow reading of the datetime2 field as a date?
I don’t want to get into a power struggle and try to force them to change all the datetime2 fields to datetime. We don’t nor do we intend to use anything less than 1/100 of a second.
Nice. New to the SSMS 2008. Thanks
[...] In case of GETDATE, the precision is till milliseconds, and in case of SYSDATETIME, the precision is till nanoseconds.(Read More Here) [...]
No i didn’t know this, thanks for sharing …
Please refer this
http://wiki.evident.nl/Default.aspx?Page=SYSDATETIME%20versus%20GETDATE&AspxAutoDetectCookieSupport=1
No dint know.. :( TFS..
NO..I DONT KNOW…
THANKS FOR SHARING SIR…
-SKC
Thanks for Sharing Sir….Gr8….!
[...] Questions and Answers ISBN: 1466405643 Page#133 Difference Between DATETIME and DATETIME2 Difference Between GETDATE and SYSDATETIME Get Time in Hour:Minute Format from a Datetime – Get Date Part Only from Datetime Datetime [...]
Thank for your post
I’m searching the right function for setting datetime2 and your post give me the answere.
You can use these functions when you generate time related reports like employee working hour report or for logs….
I just ran into a problem where I got this exception
“The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value”
So I looked at you description of datetime2 and datetime and came here to see the real diffrence.
Thanks.
I really don’t know this. thanks a lot and also this sites help me a lot when i am in difficult situation.
Thanks
I was also not aware of this. While trying this function, I came across another function called SYSDATETIMEOFFSET in which the your time zone offset is also included.
select SYSDATETIMEOFFSET()
Result : 2012-08-07 15:06:55.4932851 -04:00
Thanks Pinal. Really its good.
Didn’t know… Thanks! Any idea why the time from getdate() and sysdatetime() are so different? SQL 2008 they often differ by .010 seconds, see this example:
PRINT DATEDIFF(ms,GETDATE(),SYSDATETIME())
WAITFOR DELAY ’00:00:00.01′
go 50
[...] Difference Between GETDATE and SYSDATETIME [...]
Thanks
Wonderful article..
Hi , i want date as
jan twenty eighth 2001 in ms sql.
If you want to show formatted dates in front end application, do the formation there
Thanks Pinal…
Your blog is very useful…..
Thanks pinal…..was totally unaware of sysdatetime…..