If you are a regular reader of this blog – you will find no issue at all in resolving this puzzle. This contest is based on my experience with NuoDB.
If you are not familiar with NuoDB, here are few pointers for you.
- Step by Step Guide to Download and Install NuoDB – Getting Started with NuoDB
- Quick Start with Admin Sections of NuoDB – Manage NuoDB Database
- Quick Start with Explorer Sections of NuoDB – Query NuoDB Database
In today’s contest you have to answer following questions:
Q 1: Precision of NOW()
What is the precision of the NuoDB’s NOW() function, which returns current date time?
Hint: Run following script on NuoDB Console Explorer section:
SELECT NOW() AS CurrentTime FROM dual;
Here is the image. I have masked the area where the time precision is displayed.
Q 2: Executing Date and Time Script
When I execute following script –
SELECT 'today' AS Today, 'tomorrow' AS Tomorrow, 'yesterday' AS Yesterday FROM dual;
I will get the following result:
Â
NOW – What will be the answer when we execute following script? and WHY?
SELECT CAST('today' AS DATE) AS Today, CAST('tomorrow' AS DATE) AS Tomorrow, CAST('yesterday'AS DATE) AS Yesterday FROM dual;
HINT: Install NuoDB (it takes 90 seconds).
Prizes:
- 2 Amazon Gifts
- 2 Limited Edition Hoodies (US resident only)
Â
Rules:
- Please leave an answer in the comments section below.
- You must answer both the questions together in a single comment.
- US resident who wants to qualify to win NuoDBÂ apparel please mention your country in the comment.
- You can resubmit your answer multiple times, the latest entry will be considered valid.
- Last day to participate in the puzzle is June 24, 2013.
- All valid answer will be kept hidden till June 24, 2013.
- The winner will be announced on June 25, 2013.
- Two Winners will get USD 25 worth Amazon Gift Card. (Total Value = 25 x 2 = 50 USD)
- The winner will be selected using a random algorithm from all the valid answers.
- Anybody with a valid email address can take part in the contest.
Reference: Pinal Dave https://blog.sqlauthority.com/ )
28 Comments. Leave new
Ans 1) NuoDB provides timestamp information to the microsecond (6 decimal places) of precision.
Query Result 2013-06-20 07:48:31.450723
Ans 2) TODAY TOMORROW YESTERDAY —> 2013-06-20 2013-06-21 2013-06-19
Reason:- Because NuoDB supports literals (‘now’, ‘today’, ‘yesterday’ and ‘tomorrow’) that can be used as values for date.
Q1: Precision of NOW().
NuoDB provides timestamp information to the microsecond (6 decimal places), so the precision will be 6.
Q2: Executing Date and Time Script.
NuoDB supports literals ‘today’, ‘yesterday’ and ‘tomorrow’ as values for date and the correct syntax is: CAST(‘today’ AS DATE) AS Today, CAST(‘yesterday’ AS DATE) AS Yesterday and CAST(‘tomorrow’ AS DATE) AS Tomorrow.
1. microsecond precision
2. the output will contain relevant dates because you’re casting as such and the sql engine is equipped to handle those string literals.
Is there any nuodb version for windows 32 bit?
Q1: Precision of NOW()
What is the precision of the NuoDB’s NOW() function, which returns current date time?
SELECT NOW() AS CurrentTime
FROM dual;
Answer: 2013-06-20 11:02:48.063512
1) NuoDB provides Time Precision of NOW () as MICROSECOND (6 decimal places).
2) NOW() is equivalent to CAST( ‘now’ AS Timestamp)
Q2: Executing Date and Time Script
What will be the answer when we execute following script? and WHY?
SELECT CAST( ‘today’ AS DATE) AS Today,
CAST(‘tomorrow’ AS DATE) AS Tomorrow,
CAST(‘yesterday’ AS DATE) AS Yesterday
FROM dual;
Output: ( If today date is 20th June, 2013)
TODAY TOMORROW YESTERDAY
———- ————- ————-
2013-06-20 2013-06-21 2013-06-19
Reason:
1) NuoDB supports literals (‘now’, ‘today’, ‘yesterday’ and ‘tomorrow’) that can be used as values for DATE.
2) Those literals are considered as strings when used for varchar
i done work on this it is very good it used a great intelligence.below i answered 2 of your question.
(1)first question answer.
today tomorrow yesterday
2013-06-20 2013-06-21 2013-06-19
2.why means
in the above query you used a cast function so the functionality of cast is to convert one data type to another it works good in “sql server.”
but “NUODB” supports literals (‘today’, ‘yesterday’ and ‘tomorrow’) that can be used as values for “date” so we can do this by using those literals and we can also use one more literal ‘now’ i done some practicals on this it seems work
In “NUODB” the use of cast function is it converts the date into required literals format
here i will show you how to use ‘now’ literal.in NUODB
select cast(‘now’ as date) from dual
once we click on execute button in nuodb we will see the today’s date.
i think my comment is some what good.
i am from INDIA,
mail id:-Munnangiavinashreddy@gmail.com
Thanks in advance,
Avinash Reddy Munnnangi.
Q1: The NOW() function returns values up to microseconds (6 decimal places).
Q2: The result is:
TODAY TOMORROW YESTERDAY
2013-06-20 2013-06-21 2013-06-19
The given strings in the CAST() function are used as literals for the DATE type.
(Iowa, USA)
Q 1: Precision of NOW()
A 1:
NOW() : no precision 2013-06-20 13:11:11
but
cast(‘now’ as timestamp) : 2013-06-20 13:11:11.074721
Q 2: Executing Date and Time Script
A 2:
Today Tomorrow Yesterday
———- ———- ———-
2013-06-20 2013-06-21 2013-06-19
Because, NuoDB supports literals (‘now’, ‘today’, ‘yesterday’ and ‘tomorrow’) that can be used as values for date.
Answer: 2013-06-20, 2013-06-21, 2013-06-19 Why: because cast define today as todays’s Date, tomorrow as tomorrow’s date and yesterday’s as yesterday’s date in NueDB
SELECT NOW() AS CurrentTime
FROM dual; — the precision is 1
SELECT CAST(‘today’ AS DATE) AS Today, — > This gives the current day date
CAST(‘tomorrow’ AS DATE) AS Tomorrow, —-> tomm date
CAST(‘yesterday’AS DATE) AS Yesterday ——> yesterday date
FROM dual;
USA
#1 – It is in fractional seconds precision (milla seconds)
#2 – Today: 2013-06-20
Tomorrow: 2013-06-21
Yesterday: 2013-06-019
CAST() as DATE. Neat how it took the string of Today and new it was a NOW() and how the others the same translation from string to DATE ADD in a sense….
Q1. MICROSECONDS
Q2.
current date, tomorrow date,yesterday date.
today,tomorrow and yesterday are date time function CAST
US,
thanks to pinal sir i am eagerly waiting for the result
ans 1. last 7 digits will be mili & nano seconds.
ans 2. dual is used when we dont now the actual table name. so it does not have any data inside. and when we execute data is not there and it will display like this. as ans 2.
1 Microseconds
2 Today,Tomorrow,Yesterday which can be used as values.
mili or nanaseconds
Today : 23/6/2013
Tomorrow : 24/6/2013
Yesterday : 22/6/2010
1) Select NOW() AS CurrentTimeFROM Dual;
Answer: 2013-06-24 16:30:20.342516
Precision of the NuoDB’s NOW() function is 6 decimal places (MICROSECOND)
2) SELECT CAST(‘today’ AS DATE) AS Today, CAST(‘tomorrow’ AS DATE) AS Tomorrow, CAST(‘yesterday’ AS DATE) AS Yesterday
FROM dual;
Answer:
TODAY TOMORROW YESTERDAY
———- ————- ————-
2013-06-24 2013-06-25 2013-06-23
Reason: ‘today’, ‘tomorrow’, ‘yesterday’, ‘now’ are the literals that can be used as values for DATE…Here we casted those literals to DATE type.
Query returns respective Today, Tomorrow, and Yesterday’s dates…
MICROSECONDS
Today’s date
tommorrow’s date
yesterday’s date
It will display exact current time in Microseconds
Today,Tomorrow,Yesterday
NuoDB is a very nice product. I downloaded it immediately after reading this artile.
Here is my answer :
Precision of NOW() will display current date
When we we execute following script we get result Today Tomorrow Yesterday