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

Answer simple quiz at the end of the blog post and –
Every day one winner from India will get Joes 2 Pros Volume 3.
Every day one winner from United States will get Joes 2 Pros Volume 3.

## 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 that 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( )
2. SYSDATETIME( )
3. GETUTCDATE( )
4. SYSUTCDATETIME( )

### Rules:

Every day one winner will be announced from United States.
Every day one winner will be announced from India.
Winner from United States will get Joes 2 Pros Volume 3.
Winner from India will get Joes 2 Pros Volume 3.
The contest is open till next blog post shows up at which is next day GTM+2.5.

Reference:  Pinal Dave (https://blog.sqlauthority.com)

## SQL SERVER – List All Objects Created on All Filegroups in Database

• GETDATE( ) is the correct answer

Ranjit — India,hyd

• Mike Michalicek
August 16, 2011 5:27 pm

USA

Mike Michalicek

• (1) GETDATE( ) is the answer

GetDate( )

The 2nd and 4th ones return time to nanoseconds not milliseconds and the 3rd and 4th return Greenwich time not my local time.

USA

• Hi Pinal,

Challenge:
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( )
2. SYSDATETIME( )
3. GETUTCDATE( )
4. SYSUTCDATETIME( )

1. GETDATE( )

Explanation:
GetDate( ) will show return the current date and time in milliseconds. SysDateTime( ) will return the current date and time in nanoseconds. GetUTCDate( ) will return the Coordinated Universal Time in milliseconds.
SysUTCDateTime( ) will return the Coordinated Universal Time in nanoseconds.

Country:
United States

Thanks for the knowledge!

Regards,

Bill Pepping

August 16, 2011 6:14 pm

Explanation:
Option 3 and 4 returns the UTC Date and Time, so they are not the correct options for this question. And Option 2 returns the date and time in local time zone but precision is in nanoseconds. So the correct answer is the option 1.

Thanks,
Basavaraj

August 16, 2011 6:15 pm

Explanation:
Option 3 and 4 returns the UTC Date and Time, so they are not the correct options for this question. And Option 2 returns the date and time in local time zone but precision is in nanoseconds. So the correct answer is the option 1.

Thanks,
Basavaraj
India

Sudeepta,
India.

• The answer is option 1 GETDATE().

• Option number 1 is the correct answer.

GETDATE( )

Country: USA

• Varinder Sandhu
August 16, 2011 7:18 pm

The correct answer is GETDATE( )

Varinder Sandhu (India)

• Nagaraj Ejanthkar
August 16, 2011 7:52 pm

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

GETDATE( )
SYSDATETIME( )
GETUTCDATE( )
SYSUTCDATETIME( )

Solution:

The right answer is Getdate().This function returns the current time zone or local date and time to the precision of milliseconds .

1 -> This function returns the current time zone date and time to the precision of milliseconds.
2 -> This function returns the current time zone date and time to the precision of 100 nano seconds or 10-7 seconds.
3 -> This function returns the Coordinated Universal Time (UTC) date and time to the precision of milliseconds.
4 -> This function returns the Coordinated Universal Time (UTC) date and time to the precision of 100 nano seconds or 10-7 seconds.

Nagaraj Ejanthkar
USA

• The correct answer is 1. GETDATE()

Brent (USA)

• Leonardo Guerrero
August 16, 2011 8:09 pm

getdate() , because show the time in milliseconds and my time zone.

SYSDATETIME( ) is not correct because, we need the time in milliseconds not in nanosecond – wrong answer

GETUTCDATE( ) In spite the time is in millisecond, is not local time, is a Universal Time – wrong answer
SYSUTCDATETIME( ) its UTC time in nanosecond, not local time – Wrong answer

Leonardo

Country: Chile

Andrew McLean
USA

• Correct Answer: Option 1 – GETDATE()

USA

• Damodaran Venkatesan
August 16, 2011 8:37 pm

Answer: 1. GetDate() gives the date and time with millisecond precision. It returns the current date and time in YYYY-MM-DD HH:MM:SSS.MMM where MMM is the millisecond portion.

Damodaran Venkatesan
USA

krishan kumar mishra (MCA)
Java Software Developer
India

• The answer is Option 1: GETDATE( )

Ramdas,NC,USA

• Option 1.

1.GETDATE( )

The precision is till miliseconds

https://blog.sqlauthority.com/2010/06/10/sql-server-difference-between-getdate-and-sysdatetime/

Thanks

Shree

Bangalore India