November 9, 2015 at 5:50 am
Easy one, thanks.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
November 9, 2015 at 7:12 am
That was an easy one, thanks.
November 9, 2015 at 7:12 am
henrik staun poulsen (11/6/2015)
Hi Steve,I think the answer should state that it is a lot safer to just write "DayOfYear" in your code.
This also makes the code easier to read.
Best regards,
Henrik
Good suggestion, thanks.
November 9, 2015 at 7:20 am
Jeff Moden (11/6/2015)
sknox (11/6/2015)
Luis Cazares (11/6/2015)
Rich Mechaber (11/6/2015)
Aaron Bertrand had a nice blog about this: scroll down for "Pop Quiz" and see if you still think DATEPART abbreviations are straightforward.Rich
2 letter abbreviations are straightforward, single letter are not. With the exception of 2 options that don't have a 2 letter abbreviation (microsecond which could be US as a representation of ยตs, and iso week which could be IW as in :sick:Oracle:sick:), all can have a standard length and in most of the cases it matches the amount of digits required.
How is it difficult to remember this: YYYY-MM-DD hh:mi:ss.ms tz ?
Well, it looks like you forgot dw, dy, wk, ww, qq, and ns...
What if you're sharing your code with absolutely anybody else? Odds are much higher they will know the difference between, for example, "day", "weekday", and "dayofyear" than "dd", "dw", and "dy".
To be honest, if they haven't taken the time to learn something so simple, they're in the wrong bloody business.
Looks like my link to Aaron Bertrand's blog provoked some conversation. Good.
I'm not advocating for one approach over another. My goal was to underscore that the "standard" abbreviations for date/time components aren't always obvious and can lead to confusion.
Oh well, I guess I'll need to brush up my resume and seek a new profession now. Apparently my inability to remember that weekday is abbreviated "dw" and not "wd" has left me unfit for a career in IT.
I've mastered the use of dust-off to dislodge crumbs and other bric-a-brac from within keyboards: is that a marketable skill?
Rich
November 9, 2015 at 7:30 am
Rich Mechaber (11/9/2015)
Jeff Moden (11/6/2015)
sknox (11/6/2015)
Luis Cazares (11/6/2015)
Rich Mechaber (11/6/2015)
Aaron Bertrand had a nice blog about this: scroll down for "Pop Quiz" and see if you still think DATEPART abbreviations are straightforward.Rich
2 letter abbreviations are straightforward, single letter are not. With the exception of 2 options that don't have a 2 letter abbreviation (microsecond which could be US as a representation of ยตs, and iso week which could be IW as in :sick:Oracle:sick:), all can have a standard length and in most of the cases it matches the amount of digits required.
How is it difficult to remember this: YYYY-MM-DD hh:mi:ss.ms tz ?
Well, it looks like you forgot dw, dy, wk, ww, qq, and ns...
What if you're sharing your code with absolutely anybody else? Odds are much higher they will know the difference between, for example, "day", "weekday", and "dayofyear" than "dd", "dw", and "dy".
To be honest, if they haven't taken the time to learn something so simple, they're in the wrong bloody business.
Looks like my link to Aaron Bertrand's blog provoked some conversation. Good.
I'm not advocating for one approach over another. My goal was to underscore that the "standard" abbreviations for date/time components aren't always obvious and can lead to confusion.
Oh well, I guess I'll need to brush up my resume and seek a new profession now. Apparently my inability to remember that weekday is abbreviated "dw" and not "wd" has left me unfit for a career in IT.
I've mastered the use of dust-off to dislodge crumbs and other bric-a-brac from within keyboards: is that a marketable skill?
Rich
Ah... sorry Rich. I didn't mean to be such a snot about all of this. I just can't believe that anyone calling the use of mostly standard abbreviations a "bad habit to kick" or a "worst practice" never mind write a highly opinionated section of a article on such things. :sick:
BTW... proper inversion of a keyboard and shaking it vigorously is a much sought after skill. ๐
--Jeff Moden
Change is inevitable... Change for the better is not.
November 9, 2015 at 7:35 am
Jeff Moden (11/9/2015)
Rich Mechaber (11/9/2015)
Jeff Moden (11/6/2015)
sknox (11/6/2015)
Luis Cazares (11/6/2015)
Rich Mechaber (11/6/2015)
Aaron Bertrand had a nice blog about this: scroll down for "Pop Quiz" and see if you still think DATEPART abbreviations are straightforward.Rich
2 letter abbreviations are straightforward, single letter are not. With the exception of 2 options that don't have a 2 letter abbreviation (microsecond which could be US as a representation of ยตs, and iso week which could be IW as in :sick:Oracle:sick:), all can have a standard length and in most of the cases it matches the amount of digits required.
How is it difficult to remember this: YYYY-MM-DD hh:mi:ss.ms tz ?
Well, it looks like you forgot dw, dy, wk, ww, qq, and ns...
What if you're sharing your code with absolutely anybody else? Odds are much higher they will know the difference between, for example, "day", "weekday", and "dayofyear" than "dd", "dw", and "dy".
To be honest, if they haven't taken the time to learn something so simple, they're in the wrong bloody business.
Looks like my link to Aaron Bertrand's blog provoked some conversation. Good.
I'm not advocating for one approach over another. My goal was to underscore that the "standard" abbreviations for date/time components aren't always obvious and can lead to confusion.
Oh well, I guess I'll need to brush up my resume and seek a new profession now. Apparently my inability to remember that weekday is abbreviated "dw" and not "wd" has left me unfit for a career in IT.
I've mastered the use of dust-off to dislodge crumbs and other bric-a-brac from within keyboards: is that a marketable skill?
Rich
Ah... sorry Rich. I didn't mean to be such a snot about all of this. I just can't believe that anyone calling the use of mostly standard abbreviations a "bad habit to kick" or a "worst practice" never mind write a highly opinionated section of a article on such things. :sick:
BTW... proper inversion of a keyboard and shaking it vigorously is a much sought after skill. ๐
Hah, no harm, no foul Jeff. It's a curious fact that the least consequential choices in IT often generate the most vigorous, passionate arguments. Much like marriage, child-rearing, religion, and politics -- but with per-processor licensing.
๐
Rich
November 9, 2015 at 7:39 am
Jeff Moden (11/9/2015)
Rich Mechaber (11/9/2015)
Jeff Moden (11/6/2015)
sknox (11/6/2015)
Luis Cazares (11/6/2015)
Rich Mechaber (11/6/2015)
Aaron Bertrand had a nice blog about this: scroll down for "Pop Quiz" and see if you still think DATEPART abbreviations are straightforward.Rich
2 letter abbreviations are straightforward, single letter are not. With the exception of 2 options that don't have a 2 letter abbreviation (microsecond which could be US as a representation of ยตs, and iso week which could be IW as in :sick:Oracle:sick:), all can have a standard length and in most of the cases it matches the amount of digits required.
How is it difficult to remember this: YYYY-MM-DD hh:mi:ss.ms tz ?
Well, it looks like you forgot dw, dy, wk, ww, qq, and ns...
What if you're sharing your code with absolutely anybody else? Odds are much higher they will know the difference between, for example, "day", "weekday", and "dayofyear" than "dd", "dw", and "dy".
To be honest, if they haven't taken the time to learn something so simple, they're in the wrong bloody business.
Looks like my link to Aaron Bertrand's blog provoked some conversation. Good.
I'm not advocating for one approach over another. My goal was to underscore that the "standard" abbreviations for date/time components aren't always obvious and can lead to confusion.
Oh well, I guess I'll need to brush up my resume and seek a new profession now. Apparently my inability to remember that weekday is abbreviated "dw" and not "wd" has left me unfit for a career in IT.
I've mastered the use of dust-off to dislodge crumbs and other bric-a-brac from within keyboards: is that a marketable skill?
Rich
Ah... sorry Rich. I didn't mean to be such a snot about all of this. I just can't believe that anyone calling the use of mostly standard abbreviations a "bad habit to kick" or a "worst practice" never mind write a highly opinionated section of a article on such things. :sick:
BTW... proper inversion of a keyboard and shaking it vigorously is a much sought after skill. ๐
It isn't the first time this discussion has been around here. I remember one of them where Jeff basically stated I have no right to even turn on a computer. ๐
This topic is highly opinionated and I agree that for the everyday abbreviations they are pretty simple. It is just that some of them are downright challenging to remember. I find that dd for day and dy for dayofweek are easy for me to get confused. I have to look those two up every single time I come across them. I am pretty sure that after almost 20 years I am just not going to remember them. ๐
I think this one really kind of boils down to the same discussion as naming conventions or code formatting. You should stick to the conventions in the environment where you work.
_______________________________________________________________
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/
November 9, 2015 at 7:47 am
sknox (11/6/2015)
Luis Cazares (11/6/2015)
sknox (11/6/2015)
Luis Cazares (11/6/2015)
Rich Mechaber (11/6/2015)
Aaron Bertrand had a nice blog about this: scroll down for "Pop Quiz" and see if you still think DATEPART abbreviations are straightforward.Rich
2 letter abbreviations are straightforward, single letter are not. With the exception of 2 options that don't have a 2 letter abbreviation (microsecond which could be US as a representation of ยตs, and iso week which could be IW as in :sick:Oracle:sick:), all can have a standard length and in most of the cases it matches the amount of digits required.
How is it difficult to remember this: YYYY-MM-DD hh:mi:ss.ms tz ?
Well, it looks like you forgot dw, dy, wk, ww, qq, and ns...
What if you're sharing your code with absolutely anybody else? Odds are much higher they will know the difference between, for example, "day", "weekday", and "dayofyear" than "dd", "dw", and "dy".
Aren't those self explanatory? If they don't know the difference, selecting the function and pressing F1 will take them to the page on BOL.
Those two sentences are self-contradictory: If the terms were self-explanatory then by definition they would not need too be looked up; therefore the advice to look them up on BOL undermines your assertion that they are.
How can a question and an affirmation be self-contradictory? I'm making the question because those are self explanatory for me, but if someone asks me what they mean, I can lead them to find the answer on their own.
By the way, these should be easily understood by an English speaker (native or not), but I've had to deal with many colleagues that don't speak English and need to figure this out by going to BOL.
November 9, 2015 at 1:53 pm
Luis Cazares (11/9/2015)
How can a question and an affirmation be self-contradictory? I'm making the question because those are self explanatory for me, but if someone asks me what they mean, I can lead them to find the answer on their own.By the way, these should be easily understood by an English speaker (native or not), but I've had to deal with many colleagues that don't speak English and need to figure this out by going to BOL.
A rhetorical question is a statement in the form of a question, so you really do have two statements, not a question and a statement.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
November 9, 2015 at 2:14 pm
drew.allen (11/9/2015)
Luis Cazares (11/9/2015)
How can a question and an affirmation be self-contradictory? I'm making the question because those are self explanatory for me, but if someone asks me what they mean, I can lead them to find the answer on their own.By the way, these should be easily understood by an English speaker (native or not), but I've had to deal with many colleagues that don't speak English and need to figure this out by going to BOL.
A rhetorical question is a statement in the form of a question, so you really do have two statements, not a question and a statement.
Drew
Just a note:
Extract from here
Though a rhetorical question does not require a direct answer, in many cases it may be intended to start a discussion
November 9, 2015 at 2:23 pm
Rich Mechaber (11/9/2015)
Oh well, I guess I'll need to brush up my resume and seek a new profession now. Apparently my inability to remember that weekday is abbreviated "dw" and not "wd" has left me unfit for a career in IT.
Me too, it seems. Maybe I'll go build some space ships after all. ๐
(though it's the 'mi' that catches me way too often. Either I can't remember it at all, or I use mm and wonder for a few moments why my results are several years wrong)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 11 posts - 31 through 40 (of 40 total)
You must be logged in to reply to this topic. Login to reply