November 6, 2015 at 8:27 am
Only someone with absolutely no experience on IT would use dy as a representation of day.
Unless they meant to type the full name and fat fingered the a and turned on caps lock or something. ๐
_______________________________________________________________
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 6, 2015 at 8:29 am
Luis Cazares (11/6/2015)
Sean Lange (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 ?
The 2 letter abbreviations are better but some of them are still difficult to remember. dw for weekday is a good example. And dd for day instead of dy is a little off but of course that is because dy is for dayofyear. And microsecond just doesn't have a reasonable 2 character shortcut. When reading code I can usually get it right but I have to stop and look at it. In the middle of a bunch of code dw is not nearly as easy to remember as weekday. It of course boils down to preference. I have to say that for so many people who don't mind the extra characters to be clear and precise for things like never leaving off the schema it seems contrary when the argument is made to use abbreviations for date parts. Just my 2ยข.
I'm not saying that using 2 letter abbreviations is the correct way to go. I won't correct code to use one or the other. I just don't get that people say that abbreviations should be avoided because they're dangerous.
It's one of those things that just will keep as a constant debate, such as leading commas and trailing commas. And no, I don't want to start a debate on that. ๐
I agree that saying they are dangerous is a bit ridiculous. I don't like the abbreviations but that is because they slow me down, not because they are dangerous.
The leading/trailing comma is down to code formatting and we all have our own opinions on code formatting.
_______________________________________________________________
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 6, 2015 at 10:09 am
Luis Cazares (11/6/2015)
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.
Have any idea how many machines I've connected to that don't have BOL installed since they've made is a pain to get it working in modern SQL versions? Many, especially from a remote desktop.
It's very, very annoying.
November 6, 2015 at 10:14 am
Sean Lange (11/6/2015)
Only someone with absolutely no experience on IT would use dy as a representation of day.
Unless they meant to type the full name and fat fingered the a and turned on caps lock or something. ๐
...or vice versa. meant to type dy and hit the a in the middle. Yup. I'm fat fingered!
Gerald Britton, Pluralsight courses
November 6, 2015 at 10:53 am
Steve Jones - SSC Editor (11/6/2015)
Luis Cazares (11/6/2015)
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.Have any idea how many machines I've connected to that don't have BOL installed since they've made is a pain to get it working in modern SQL versions? Many, especially from a remote desktop.
It's very, very annoying.
I don't have BOL installed in my work computer, when I hit F1 it opens a browser page.
November 6, 2015 at 11:10 am
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. Since DD is a standard across all the systems that I've used to represent the day, I don't get where's the confusion. Only someone with absolutely no experience on IT would use dy as a representation of day.
Yes, they are self-explanatory. Another important point about shared code is that the recipient should know and understand how it works, which means they need to spend time with it. If they don't understand it, they shouldn't use it.
November 6, 2015 at 5:05 pm
g.britton (11/6/2015)
Ed Wagner (11/6/2015)
There is debate over which form to use - the full or abbreviation. The cool part is that both work. ๐Cool part? Or Dangerous part? Too easy to type "dy" when you mean "day" or vice versa.
Not if you actually know what you're doing. ๐ IMHO, consistent use of the 2 character abbreviations is like using a "+" instead of the word "plus" in simple math formulas.
Of course, MS had to screw that up with ISOWK instead of the much more appropriate "IW" (pronounced "ewwww" ๐ ) and that gosh awful "mcs" (micro second) instead of the very much more standard "us".
--Jeff Moden
Change is inevitable... Change for the better is not.
November 6, 2015 at 5:10 pm
Luis Cazares (11/6/2015)
Steve Jones - SSC Editor (11/6/2015)
Luis Cazares (11/6/2015)
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.Have any idea how many machines I've connected to that don't have BOL installed since they've made is a pain to get it working in modern SQL versions? Many, especially from a remote desktop.
It's very, very annoying.
I don't have BOL installed in my work computer, when I hit F1 it opens a browser page.
Which is fine, until the day you're working on a server that has no internet access (or on a plane)
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
November 6, 2015 at 5:12 pm
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
Yes... I still think that the "first column" 2 character abbreviations are both appropriate and very easy to remember. If someone can't remember that MM is month and that MI is minute, then they should study a bit more.
For really complex formulas, I find the written out date parts are annoying especially since the coloring of many of them looks like a function instead of a parameter. I also find the different lengths to be "alignment resistant" when formatting for readability.
Of course, that's just my opinion on it. It's kind of like me thinking that anyone calling themselves "DBA" on their resume should actually know how to get the current date and time using a SELECT. ๐
--Jeff Moden
Change is inevitable... Change for the better is not.
November 6, 2015 at 5:16 pm
Sean Lange (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 ?
The 2 letter abbreviations are better but some of them are still difficult to remember. dw for weekday is a good example. And dd for day instead of dy is a little off but of course that is because dy is for dayofyear. And microsecond just doesn't have a reasonable 2 character shortcut. When reading code I can usually get it right but I have to stop and look at it. In the middle of a bunch of code dw is not nearly as easy to remember as weekday. It of course boils down to preference. I have to say that for so many people who don't mind the extra characters to be clear and precise for things like never leaving off the schema it seems contrary when the argument is made to use abbreviations for date parts. Just my 2ยข.
"dw" is easy for me to remember because "DoW" is a standard for "Day of Week" and dropping the "o" is quite common. MS actually mis-defined it because, by definition, a "weekday" does not include Saturday or Sunday.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 6, 2015 at 5:18 pm
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. Since DD is a standard across all the systems that I've used to represent the day, I don't get where's the confusion. Only someone with absolutely no experience on IT would use dy as a representation of day.
Exactly. +1000
--Jeff Moden
Change is inevitable... Change for the better is not.
November 6, 2015 at 5:22 pm
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.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 6, 2015 at 5:30 pm
To be honest, I've started to use full words for the time components. I've mixed up mm and mi one too many times.
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
November 6, 2015 at 6:00 pm
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.
November 7, 2015 at 5:30 am
Good question.
I am surprised by the inconsistence of the T-SQL :
why to have weekday ( day of the week ) and dayofyear ( day of the year ) ? I would prefer dayofweek ( easier to remember ). Maybe to avoid to type 2 more letters ?
Viewing 15 posts - 16 through 30 (of 40 total)
You must be logged in to reply to this topic. Login to reply