SQL SERVER – Lots of Date Functions – Find Right One to Use – Quiz – Puzzle – 27 of 31

SQL Server Interview Questions and Answers
Print Book Available (207 Pages) | Sample Chapters

Year 2011 was a year of learning and opportunity for me. My recent book, SQL Server Interview Questions and Answers, has received such overwhelming love and support from all of you. While writing the book, I had two simple goals: (1) Master the Basics and (2) Ignite Learning. There was a constant request from the Community to take the learning of these books to the next level. Here is an article which discusses the Author’s Perspective.

Beyond Relational has come up with a very interesting concept – they have converted a few of the questions from my book into the SQL Quiz. The quiz is indeed focused on my two goals. In addition, it’s going to put the learning of the book to a higher stage. Looking at this novel concept, Vinod Kumar (Co-author) and I have decided to help every participant and reader by giving a few hints and suggestions to solve the quiz.

SQL Quiz

27 SQL SERVER   Lots of Date Functions   Find Right One to Use   Quiz   Puzzle   27 of 31Using datetime functions inside SQL Server have always been a struggle even if there are multiple options. There have been interesting usages of GETDATE, but appealing functions like SYSDATETIME(), GETUTCDATE() and SYSYTCDATETIME() functions were also introduced. When would you use these functions and what are their differences?

Link to participate in SQL Quiz

Notes of Vinod Kumar

GETDATE() from the SQL Server 2000 days has been a common function which developers started to utilize. To answer the question, read the hint here. The changes on usage are fascinating as the precision levels and storage needs of these can be altered drastically. Can you name some of these changes?

Notes of Pinal Dave

I remember an old story told to me when I was just a beginning DBA. I had set up a job which was supposed to run at exact 12 AM (midnight). After a few runs, we realized that the job was running always 30 seconds earlier than the desired time. Every single day, at precisely 30 seconds before 12 AM, it would start to run. After a while, we had to create a complete investigation team on this subject. A senior DBA eventually figured it out – it was because we had used SMALLDATETIME datatype for a variable. This variable was storing the current datetime, and as precision of SMALLDATETIME is in terms of minutes, we had to face that issue. Our IT manager finally made all of us to go through every single datatype available in the SQL Server and get familiarized with all of them. I learned the lesson very well so now I want to share this experience with everybody.

Additional Notes

SQL Server Interview 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 Function TODATETIMEOFFSET Example
Information Related to DATETIME and DATETIME2
Datetime Function SWITCHOFFSET Example
DATE and TIME in SQL Server 2008


There are exciting prizes awaiting the winners. Click here for Prizes and Frequently Asked Questions.

Link to participate in SQL Quiz

Note: SQL Quiz, winners and prizes are administrated by Beyond Relational. The goal of this blog post is to provide additional learning pointers only.

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

One thought on “SQL SERVER – Lots of Date Functions – Find Right One to Use – Quiz – Puzzle – 27 of 31

  1. Pingback: SQL SERVER – Weekly Series – Memory Lane – #014 « SQL Server Journey with SQL Authority

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s