# 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 – Unable to Start SQL Service – OS Error 5 (Access is denied.) for TempDB

• Hi,

I am from India

• Hi Pinal Dave,

GetDate() is the function that will return the date and time in the current time zone expressed in milliseconds.

David, USA

• 1.GETDATE( )

Gordon Kane
Allen TX
USA

• Inorder to get the desired precision, the correct answer is:
1.GETDATE( )

Country: United States

• hii pinal dave,

GetDate()

• dilipkumarjena
August 16, 2011 11:43 pm

The answer for Question 16 is Option 1) GETDATE( ).

Why Explanation:

We need a Function which will return the date and time in the current time zone to a precision of milliseconds as we have seen that your time zone by is nothing but default time zone.

But GETUTCDATE( ) returns the time in milliseconds but here we need is current time zone or our zone.

Hence the correct Option is Option 1 .

Option 2) SYSDATETIME( ) will return the time in nanoseconds but we need time in millisconds so invalid answer.

Option 3) GETUTCDATE( ) and Option 4) SYSUTCDATETIME( ) will return UTC time which is not required hence ruled out.

DILIP KUMAR JENA
Country : INDIA

August 17, 2011 12:10 am

1.GETDATE( )

Vinay
Pune,India

• 1. getDate()

Rishi Divecha
Iselin, NJ
USA

• Select Getdate()
to the precision of milliseconds
USA

• Nikhil Mahajan
August 17, 2011 8:48 am

ie. Select Getdate()
because

GETDATE( ) shows fractional seconds expressed in milliseconds

india

• Correct Answer Option No. 1

GETDATE() Shows current date with miliseconds

Somnath Desai

India

• GETDATE( ) is the correct answer

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

A.) A

Winner from USA: Shikha Gupta

Winner from India: Rajneesh Verma

I thank you all for participating here. The permanent record of this update is posted on facebook page.

• GETDATE() ..

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

1. GETDATE()

• Hi Pinal,
The correct answer is option 1 GETDATE()

Ques:-Which option of the following functions will return the date and time in the current time zone to a precision of milliseconds?

Explanation:- As GETDATE( ) returns current date and time where in the time is having hour,minutes and fractional seconds expressed in milliseconds.

Thanks,
Manik Dey
India

• Option 1
GETDATE()

Country : India