February 27, 2017 at 9:42 pm
Comments posted to this topic are about the item Fun with Time
February 27, 2017 at 9:42 pm
Nice, easy question, thanks Steve
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
βlibera tute vulgaris exβ
February 28, 2017 at 2:08 am
Should i drink a second coffee? :crazy:
February 28, 2017 at 5:52 am
palotaiarpad - Tuesday, February 28, 2017 2:08 AMShould i drink a second coffee? :crazy:
@t is TIME, not DATETIME. That's what got me.
The explanation for this question is severely lacking in actual explanation.
February 28, 2017 at 7:58 am
I have to agree with sknox. This is a great question but I didn't actually understand the question until I read his comment. I too missed that it was a TIME datatype and was seriously confused.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 β Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
February 28, 2017 at 9:29 am
Thanks Steve for this question, yes I had a "Fun with Time", but it cost me just a little time.π
DECLARE @t TIME = GETDATE();
SELECT DATEDIFF(MINUTE, 0, @t);
--=============================================
--"Have fun with TIME", my subsequent attempts:
--=============================================
-- getdate() datetime value is implicitly converted to hh:mm:ss.nnnnnn
-- MSDN time (Transact-SQL), CAST and CONVERT (Transact-SQL)
SELECT @t;
-- If only a time value is assigned to a variable of a date data type,
-- the value of the missing date part is set to the default value: 1900-01-01.
SELECT DATEDIFF(MINUTE, '1900-01-01 00:00:00', @t);
-- startdate 0 is set to default value, enddate @t time value is set to 1900-01-01 hh:mm:ss
SELECT DATEDIFF(MINUTE, GETDATE(), @t);
SELECT DATEDIFF(MINUTE, @t, GETDATE());
SELECT DATEDIFF(MINUTE, @t, @t);
SELECT DATEADD(MINUTE,0, @t);
SELECT DATEDIFF(MINUTE, '1900-01-01 00:00:00', dateadd(MINUTE,0, @t));
February 28, 2017 at 9:34 am
George Vobr - Tuesday, February 28, 2017 9:29 AMThanks Steve for this question, yes I had a "Fun with Time", but it cost me just a little time.π
But you learned something?
February 28, 2017 at 9:46 am
Steve Jones - SSC Editor - Tuesday, February 28, 2017 9:34 AMGeorge Vobr - Tuesday, February 28, 2017 9:29 AMThanks Steve for this question, yes I had a "Fun with Time", but it cost me just a little time.πBut you learned something?
Yes, with the data type TIME I still did not work. And finally, I repeated the datetime functions, thanks.
March 9, 2017 at 3:14 pm
Truly a fun question. Thanks Steve.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply