Click here to Skip to main content
13,248,766 members (44,175 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


2 bookmarked
Posted 17 Aug 2011

SQL SERVER – Tips from the SQL Joes 2 Pros Development Series – System and Time Data Types – Day 16 of 35

, 17 Aug 2011
Rate this:
Please Sign up or sign in to vote.
Tips from the SQL Joes 2 Pros Development Series – System and Time Data Types

Answer a simple quiz at the end of the blog post and:

System and Time Data Types

Keeping track of date and time data points has always been a critical part of online transactional databases. For example, each sales invoice record needs a date-time stamp, as do systems which track quotes and customer contacts regarding sales opportunities.

Think of how many times during your workday you rely on a date-time stamp as helpful metadata to sort or locate the latest information in a report or data source. Global organizations, in particular, have a need for their in-house communication, reporting, and collaboration tools to appropriately convey accurate date and time information in order to keep every part of the organization in sync.

Recap of DateTime Functions

GETDATE( ) and SELECT SYSDATETIME( ) both return the current date and time in your time zone. However, GETDATE( ) shows fractional seconds expressed in milliseconds (.333 second), and SYSDATETIME( ) shows fractional seconds expressed in nanoseconds (.3333333 second). SYSDATETIME( ) return similar results but their precisions differ.

What time is it right now in the UK? UTC is Coordinated Universal Time, formerly known as Greenwich Mean Time (GMT). (UTC is also known by the terms zulu time, world time, and universal time.)

SELECT GETUTCDATE( ) will show the current time expressed in terms of UTC. GETUTCDATE( ) is less precise than SYSUTCDATETIME ( ). However, there is a UTC function that gets down to the nanoseconds, SYSUTCDATETIME( ). When we run all 4 of these functions together, we see the two top times in my local time zone (in my case, the Pacific time zone) and the two bottom times in UTC.

Question 16

Which one of the following functions will return the date and time in the current time zone to a precision of milliseconds?

  1. GETDATE( )


Please leave your answer in the comment section below with the correct option, explanation and your country of residence.

  • Every day, one winner will be announced from the United States.
  • Every day, one winner will be announced from India.
  • A valid answer must contain country of residence of the person who answers.
  • Please check my Facebook page for winner's name and correct answer.
  • Winner from the United States will get Joes 2 Pros Volume 3.
  • Winner from India will get Joes 2 Pros Volume 3.

The contest is open till the next blog post shows up at which is next day GTM+2.5.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

India India
Pinal Dave is a Microsoft Technology Evangelist (Database and BI). He has written over 2200 articles on the subject on his blog at Along with 8+ years of hands on experience he holds a Masters of Science degree and a number of certifications, including MCTS, MCDBA and MCAD (.NET). He is co-author of two SQL Server books - SQL Server Programming, SQL Wait Stats and SQL Server Interview Questions and Answers. Prior to joining Microsoft he was awarded Microsoft MVP award for three continuous years for his contribution in community.

You may also be interested in...


Comments and Discussions

QuestionAnswer Pin
Shining Legend29-Aug-11 0:12
memberShining Legend29-Aug-11 0:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171114.1 | Last Updated 17 Aug 2011
Article Copyright 2011 by pinaldave
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid