# 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 http://blog.sqlauthority.com which is next day GTM+2.5.

Reference:  Pinal Dave (http://blog.SQLAuthority.com)

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

1. Kamlesh |

The following functions will return the date and time in the current time zone to a precision of milliseconds:

1. GETDATE( )
2. SYSDATETIME( )

Like

2. Kamlesh |

Forgot to mention location….

The following functions will return the date and time in the current time zone to a precision of milliseconds:

1. GETDATE( )
2. SYSDATETIME( )

Option 3 and 4 are wrong answers because they will return the time in UTC format.

Thanks,
Kamlesh
Bangalore, India

Like

3. Reddy |

1.GETDATE()

becuase option #1 GETDATE() and #2 SYSDATETIME() returns date and time value with respect to CURRENT time zone, however, option #1 returns in fractional seconds expressed in milliseconds,
option #2 returns in fractional seconds expressed in nanoseconds.

Option #3 GETUTCDATE() and #4 SYSUTCDATETIME() returns the date and time value in UTC format., so these are incorrect.

Thanks.

Country – India.

Like

4. Uday Bhoopalam |

Uday Bhoopalam

Like

5. Uday Bhoopalam |

Getdate() is the correct answer it returns the date and time in our zone and the time with a milli seconds – 3position

Uday Bhoopalam
USA

Like

6. Rene Alberto Castro Velasquez |

Correct answer is No. 1 because GETDATE( ) return the date and time in the current time zone to a precision of milliseconds. Option No. 2 does the same but with a precision of nanoseconds, so is incorrect. Option 3 and 4 are incorrect beccause they return the date and time expressed in terms of UTC.
Rene Castro

Like

For DataTime in current time zone we have these :
GETDATE( ) shows fractional seconds expressed in milliseconds (.333 second),
SYSDATETIME( ) shows fractional seconds expressed in nanoseconds

USA

Like

8. 1) GETDATE( )

Option 1) is correct because the precision is to a milliseconds
Option 2) gives the system time with more frational second precision
Other 2 funtions just show the UTC times.

Leo Pius
USA

Like

9. Naomi |

Correct answer is GETDATE() (option #1) that will return current date with millisecond precision

I am from USA

Like

10. As in description “However, GETDATE( ) shows fractional seconds expressed in milliseconds (.333 second), and SYSDATETIME( ) shows fractional seconds expressed in nanoseconds (.3333333 second).” So its very clear that GETDATE( ) will return seconds expressed in Millisecond.

Option 1 is the right.

Thanks…
Rajneesh Verma
(INDIA)

Like

11. GETDATE() will returns seconds expressed in Millisecond. and
GETUTCDATE() will show in UTC format..
Both are correct.

Arjun
INDIA

Like

12. Manoj Sahoo |

GETDATE( ) is the correct answer

Scalable – Systems

Like

13. Rahul |

Option 1- GETDATE( ) is correct

Noida, INDIA

Thanks,
Rahul Sharma

Like

The correct answer is option 1 and 2 that is
1. GETDATE( )
2. SYSDATETIME( )

INDIA

Like

15. Keval |

Correct option is 1

GetDate()
This will return the result in milliseconds

INDIA

Like

16. Shikha Gupta |

The answer is Getdate() since it displays the current time zone’s date and time to the milliseconds grain.

Option 1 : It gives the current time zone’s date and time to the precision of milliseconds.
Option 2 : It gives the current time zone’s date and time to the precision of 100 nano seconds.
Option 3 : It gives the UTC date and time to the precision of milliseconds.
Option 4 : It gives the UTC date and time to the precision of 100 nano seconds.

Shikha Gupta
USA

Like

17. Pratik Raval |

Correct Answer is Option 1. GETDATE( )

Pratik Raval
India

Like

18. Correct answer is # 1.

It displays the current time zone’s date and time with respect to the milliseconds format.

Option 1 GETDATE(): It returns the current date and time in your time zone. It shows fractional seconds expressed in milliseconds (.333 second).
Option 2 SYSDATETIME(): It returns the current date and time in your time zone. But it shows fractional seconds expressed in nanoseconds (.3333333 second).
Option 3 GETUTCDATE(): It will show the current time expressed in terms of UTC. GETUTCDATE( ) is less precise than SYSUTCDATETIME ( ).
Option 4 SYSUTCDATETIME(): It will show the current time expressed in terms of UTC and it gets down to the nanoseconds.

Gopalakrishnan Arthanarisamy
Unisys, Bangalore, India

Like

19. Correct answer is # 1.

It displays the current time zone’s date and time with respect to the milliseconds format.

Option 1 GETDATE(): It returns the current date and time in your time zone. It shows fractional seconds expressed in milliseconds (.333 second).

Option 2 SYSDATETIME(): It returns the current date and time in your time zone. But it shows fractional seconds expressed in nanoseconds (.3333333 second).

Option 3 GETUTCDATE(): It will show the current time expressed in terms of UTC. GETUTCDATE( ) is less precise than SYSUTCDATETIME ( ).

Option 4 SYSUTCDATETIME(): It will show the current time expressed in terms of UTC and it gets down to the nanoseconds.

Gopalakrishnan Arthanarisamy
Unisys, Bangalore, India

Like

20. gvprabu |

Correct Answer is : Option 1 GETDATE()

— GVPrabu || BANGALORE || INDIA

Like

21. Nikhildas |

1.GETDATE()

becuase option #1 GETDATE() and #2 SYSDATETIME() returns date and time value with respect to CURRENT time zone, however, option #1 returns in fractional seconds expressed in milliseconds,
option #2 returns in fractional seconds expressed in nanoseconds.

Option #3 GETUTCDATE() and #4 SYSUTCDATETIME() returns the date and time value in UTC format., so these are incorrect.

Like

22. Nikhildas |

1.GETDATE()

becuase option #1 GETDATE() and #2 SYSDATETIME() returns date and time value with respect to CURRENT time zone, however, option #1 returns in fractional seconds expressed in milliseconds,
option #2 returns in fractional seconds expressed in nanoseconds.

Option #3 GETUTCDATE() and #4 SYSUTCDATETIME() returns the date and time value in UTC format., so these are incorrect.

Cochin,INDIA

Like

23. Sumit |

Correct option is Option #1
GETDATE( )

SYSDATETIME() returns current time zone datetime upto nanoseconds which is not required.

Option #3 GETUTCDATE() and #4 SYSUTCDATETIME() return datetime in UTC format which is also not required.

Sumit
India

Like

24. option one 1. GETDATE() is the right answer

because option 2 returns value in nonoseconds
option 3 and 4 gives value in utc date time

Tej Narayan Maurya
India

Like

25. GurjitSingh |

Option 1- GETDATE( )

City:Baroda
Country: India

Thanks,
GurjitSingh

Like

26. Sudhir Chawla |

Hi,

Option #1 GetDate() is correct. It will return in nanosecods.

Thanks

Sudhir Chawla
India

Like

27. Partha Pratim Dinda |

SELECT GETDATE( )

GETDATE( ) shows fractional seconds expressed in milliseconds ,
and SYSDATETIME( ) shows fractional seconds expressed in nanoseconds

GETUTCDATE( ) will show the current time expressed in terms of UTC. SYSUTCDATETIME ( ) will show curretnt time gets down to the nanoseconds.

Like

28. Narendra |

GETDATE() will gives the correct date and time with the precission of milliseconds.

Thanks,
Narendra (India)

Like

29. Fazal Vahora |

getdate() returns current time zone details with milliseconds precision.

Thanks,
Fazal

Like

30. Fazal Vahora |

getdate() returns current time zone details with milliseconds precision.

Country:India

Thanks,
Fazal

Like

31. santosh.s |

Option 1 is correct. Because

1) GETDATE() returns a DATETIME value. A DATETIME value has precision upto 3 milliseconds.

2) SYSDATETIME() returns a DATETIME2 value. which gives precision upto 100nanoseconds

Thanks
Santosh.S
Bangalore

Like

32. abhishek mishra |

because GETDATE( ) gives fractional seconds expressed in milliseconds
and GETUTCDATE( ) will show the current time expressed in milliseconds terms of UTC

Abhishek MIshra
INDIA NOIDA

Like

33. Sudhir Chawla |

Hi,

Option #1 GetDate() is correct. It will return in milliseconds not nanoseconds.

Thanks

Sudhir Chawla
India

Like

34. Anish Shenoy.P |

Hi Sir,

Option 1 is the correct answer as GETDATE() will return the date and time in the current time zone to a precision of milliseconds (.333 second).

option 2 SYSDATETIME() will return the date and time in the current time zone to a precision of nanoseconds (.3333333 second).

Option 3 GETUTCDATE() will show the current time expressed in terms of UTC to a precision of milliseconds.

Option 4 SYSUTCDATETIME() will show the current time expressed in terms of UTC to a precision of nanoseconds.

So the correct answer is Option no 1 GETDATE().

P.Anish Shenoy,
INDIA, Bangalore, Karnataka

Like

35. sravan |

Correct Option is 1

i.e. 1) GETDATE() which gives date and time and the precision to milliseconds.

I’m from INDIA

Like

36. Mohd Thoufeek |

The Correct answer is : #1

GETDATE( )

Mohd Thoufeek
chennai-india

Like

37. Correct Answer is Option 1

Explanation:
1)GETDATE() returns date time in miliseconds.
Example:
SELECT GETDATE()

Thanks
Vishal Patwardhan
Indore(India)

Like

38. hello,
correct answer is option #1 i.e: getdate()

getdate(): it will return the date and time in the current time zone to a precision of milliseconds
sysdatetime(): nano seconds

from mumbai,india

Like

Like

40. Luchian Ioana |

GETDATE() returns date time in miliseconds.
Romania

Like

41. Pritesh Mehat |

1.GETDATE()

Pritesh Mehat
India

Like

42. Pritesh Mehta |

1.GETDATE()

Pritesh Mehta
India

Like

43. Mandar Alawani |

1) GETDATE()

Thanks,
Mandar
Mumbai, INDIA

Like

44. Correct Answer: GetDate() option 1

Purna from INDIA

Like

45. Diljeet kumari |

Hi Pinal,

The answer for the above question is Option 1) GETDATE( ).

Explanation:

Asked : Function will return the date and time in the current time zone to a precision of milliseconds.

Explanation : Here we need to find out Current time zone in the above article it is very beautifully explained by pinal sir that GETDATE() will return current date and time in your time zone by default your time zine is said as default time zone though GETUTCDATE( ) returns the same in milliseconds but here our requirement is current time zone, i.e our zone.

Apart from that no other option will give us that result.

Diljeet kumari

Country : India

Like

46. Correct option is #1

SYSDATETIME() returns current time zone datetime upto nanoseconds which is not required.

INDIA

Like

47. Hiren Bavishi |

1. GETDATE()

GETDATE() will return current date and time in current time zone with precision of milliseconds.

Hiren Bavishi
India

Like

48. Correct Answer is Option 1

Explanation: Option 3 and 4 provide date and time in Universal Time Coordinates (UTC) and option 2 provide date and time in current time zone but with precision of nanoseconds.
Option 1 provide date and time in current time zone to a precision of milliseconds.

Country – INDIA (Gujarat)

Like

49. Mangesh |

Option 1 is correct

Mangesh From India

Like

50. Option 2. SYSDATETIME( ), will return the date and time in the current time zone to a precision of milliseconds.

(Sale, Nigeria)

Like

51. Truptee Patil |

option #1 GETDATE( ) is correct as it the date and time in the current time zone to a precision of milliseconds

Like

52. Shalini.M |

Question No:16
Answer : GETDATE() — Option 1

Shalini Meyyappan
Chennai India.

Like

53. Shekhar Gurav. |

Correct Answer is option No : 1 ) GETDATE( )

GETDATE( ) returns current time zone details with milliseconds precision.

Shekhar Gurav
Country : INDIA

Like

54. Deepali Bhende |

The correct answer is option 1 :
1. GETDATE( )
It shows fractional seconds expressed in milliseconds.

Deepali Bhende.
Country : INDIA

Like

55. Correct Option is 1

GETDATE() which gives date and time and the precision to milliseconds.

Regards
Rajesh

From India

Like

56. Ranjit kumar |

GETDATE( ) is the correct answer

Ranjit — India,hyd

Like

57. Mike Michalicek |

USA

Mike Michalicek

Like

58. Deb |

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

Like

59. Bill Pepping |

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

Like

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

Like

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

Like

61. sudeepta |

Sudeepta,
India.

Like

62. Ashley Pace |

The answer is option 1 GETDATE().

Like

63. Kunal Gosar |

Like

64. Option number 1 is the correct answer.

GETDATE( )

Country: USA

Like

65. Nagaraj Ejanthkar |

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

Like

66. Brent |

The correct answer is 1. GETDATE()

Brent (USA)

Like

67. Leonardo Guerrero |

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

Like

68. Andrew McLean |

Andrew McLean
USA

Like

Correct Answer: Option 1 – GETDATE()

USA

Like

70. Damodaran Venkatesan |

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

Like

krishan kumar mishra (MCA)
Java Software Developer
India

Like

72. The answer is Option 1: GETDATE( )

Ramdas,NC,USA

Like

73. David Brust |

Hi Pinal Dave,

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

David, USA

Like

74. Gordon Kane |

1.GETDATE( )

Gordon Kane
Allen TX
USA

Like

75. Don |

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

Country: United States

Like

76. shail |

hii pinal dave,

GetDate()

Like

77. 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

Like

78. JOHN |

Select Getdate()
to the precision of milliseconds
USA

Like

ie. Select Getdate()
because

GETDATE( ) shows fractional seconds expressed in milliseconds

india

Like

80. Somnath |

GETDATE() Shows current date with miliseconds

Somnath Desai

India

Like

81. Ariel Lopez |

GETDATE( ) is the correct answer

Like

82. Pankaj |

GETDATE() ..

Like

83. Peter Spencer |

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

1. GETDATE()

Like

84. Manik Dey |

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

Like

85. sachin |

Correct Answer is Option I & II

Like

86. I think the correct answer is both No. 1 because GETDATE( ) return the date and time in the current time zone to a precision of milliseconds and No. 2 becauseSysDateTime does the same thing but with higher precision. Both are accurate to the millisecond.

Like