January 1, 2016 at 1:08 pm
It almost looks like there should be an additional radio selection, the last one.
January 1, 2016 at 7:05 pm
Happy New Year, Steve! Thank you for all that you do for this wonderful community!
--Jeff Moden
Change is inevitable... Change for the better is not.
January 4, 2016 at 4:57 am
Great question. Best wishes for everyone.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
January 4, 2016 at 6:40 am
Even if it is not commented out, option four returns two values, only one of them the right one, so really guessing the intent of the is borderline impossible.
January 4, 2016 at 9:31 am
Xavon (1/4/2016)
Even if it is not commented out, option four returns two values, only one of them the right one, so really guessing the intent of the is borderline impossible.
Ah, that's the issue. Cut and pasted too much. Was only supposed to be the second one.
The answer boxes are small, so it's hard to see longer code samples and I missed that.
Points awarded back.
January 4, 2016 at 9:36 am
Cut and paste issues hit us all -- even to the experienced.
LinkedIn: https://www.linkedin.com/in/sqlrv
Website: https://www.sqlrv.com
January 4, 2016 at 10:32 am
Aaron N. Cutshall (1/4/2016)
Cut and paste issues hit us all -- even to the experienced.
Especially to the experienced - the inexperienced are more likely to check things afterwards 🙂
January 4, 2016 at 2:04 pm
Toreador (1/4/2016)
Aaron N. Cutshall (1/4/2016)
Cut and paste issues hit us all -- even to the experienced.Especially to the experienced - the inexperienced are more likely to check things afterwards 🙂
+1 for the experienced but the proof of a good creator of QOD is to recognize it.
So , Steve , +1 for you and thank you very much to recognize the error ( the explanation is interesting and could apply to some other "erroneous or not easily understandable QOD ).
Anyway , I have learnt about English/us words...
January 4, 2016 at 2:20 pm
Good question. Just one minor thing, I'd use the following the end of the calendar year:
SELECT DATEADD(DAY, -1, DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()) + 1, 0));
January 4, 2016 at 3:11 pm
Lynn Pettis (1/4/2016)
Good question. Just one minor thing, I'd use the following the end of the calendar year:
SELECT DATEADD(DAY, -1, DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()) + 1, 0));
So short and good way...
+1 and thanks
January 4, 2016 at 3:21 pm
Lynn Pettis (1/4/2016)
Good question. Just one minor thing, I'd use the following the end of the calendar year:
SELECT DATEADD(DAY, -1, DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()) + 1, 0));
Slow / lazy typer
😎
SELECT DATEFROMPARTS(YEAR(GETDATE()),12,31)
or
SELECT DATETIMEFROMPARTS(YEAR(GETDATE()),12,31,0,0,0,0)
January 4, 2016 at 3:24 pm
Lynn Pettis (1/4/2016)
Good question. Just one minor thing, I'd use the following the end of the calendar year:
SELECT DATEADD(DAY, -1, DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()) + 1, 0));
With the understanding that both -1's (1899-12-31) are in a year earlier than 0 (1900-01-01), you can get way with murder.
SELECT DATEADD(yy,DATEDIFF(yy,-1,GETDATE()),-1); --Last Day of Current Year
--Jeff Moden
Change is inevitable... Change for the better is not.
January 4, 2016 at 3:30 pm
Jeff Moden (1/4/2016)
Lynn Pettis (1/4/2016)
Good question. Just one minor thing, I'd use the following the end of the calendar year:
SELECT DATEADD(DAY, -1, DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()) + 1, 0));
With the understanding that both -1's (1899-12-31) are in a year earlier than 0 (1900-01-01), you can get way with murder.
SELECT DATEADD(yy,DATEDIFF(yy,-1,GETDATE()),-1); --Last Day of Current Year
Never imagined I would ever boost in this way but mine is (4 characters) shorter than yours:-D
😎
Edit: parenthesis
January 4, 2016 at 3:36 pm
Eirikur Eiriksson (1/4/2016)
Jeff Moden (1/4/2016)
Lynn Pettis (1/4/2016)
Good question. Just one minor thing, I'd use the following the end of the calendar year:
SELECT DATEADD(DAY, -1, DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()) + 1, 0));
With the understanding that both -1's (1899-12-31) are in a year earlier than 0 (1900-01-01), you can get way with murder.
SELECT DATEADD(yy,DATEDIFF(yy,-1,GETDATE()),-1); --Last Day of Current Year
Never imagined I would ever boost in this way but mine is (4 characters) shorter than yours:-D
😎
Edit: parenthesis
You got me beat too.
SELECT CAST(CAST(YEAR(GETDATE()) AS CHAR(4)) + '1231' AS DATE)
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
January 4, 2016 at 3:54 pm
Alvin Ramard (1/4/2016)
Eirikur Eiriksson (1/4/2016)
Jeff Moden (1/4/2016)
Lynn Pettis (1/4/2016)
Good question. Just one minor thing, I'd use the following the end of the calendar year:
SELECT DATEADD(DAY, -1, DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()) + 1, 0));
With the understanding that both -1's (1899-12-31) are in a year earlier than 0 (1900-01-01), you can get way with murder.
SELECT DATEADD(yy,DATEDIFF(yy,-1,GETDATE()),-1); --Last Day of Current Year
Never imagined I would ever boost in this way but mine is (4 characters) shorter than yours:-D
😎
Edit: parenthesis
You got me beat too.
SELECT CAST(CAST(YEAR(GETDATE()) AS CHAR(4)) + '1231' AS DATE)
Shorter version of yours, same length as mine:Whistling:
😎
SELECT EOMONTH(STR(YEAR(GETDATE()))+'1231')
Viewing 15 posts - 16 through 30 (of 35 total)
You must be logged in to reply to this topic. Login to reply