What Were Your 2021 Wins

LinkedIn sent me a prompt just before Christmas that asked me to write a post on my 2021 wins, using the #2021wins hashtag. I thought it was a neat idea, and I blogged on this topic before I left for my final vacation. I primarily had work items in there, though a couple of work-related things. To me, while 2021 was disappointing in some ways, it was still a great year for me in many ways, and I’ve tried to keep that in mind. Not focus on things that didn’t go well but those that did.

It’s the first week of the new year, and many of you are likely starting to look forward at work and in your career. You might have made resolutions, or maybe you are just re-focusing after the holidays. Either way, on this Friday I’d like you to think back to last year, focusing on how your career might have changed throughout the second year of the COVID pandemic.

What was a career win for you in 2021?

That’s the question. It could be a change that you made, a skill you learned, a project you completed, maybe an award. Perhaps it was something that happened and you just experienced. Maybe an event or talk that inspired you or changed the outlook on something.

I’d like to think that all of you had at least one good thing happen in your career last year. Take a minute and share in your win and congratulate others for theirs.

Steve Jones

Listen to the podcast at Libsyn, Stitcher, Spotify, or iTunes.

Posted in Editorial | Tagged | Comments Off on What Were Your 2021 Wins

Daily Coping 7 Jan 2022

I started to add a daily coping tip to the SQLServerCentral newsletter and to the Community Circle, which is helping me deal with the issues in the world. I’m adding my responses for each day here. All my coping tips are under this tag.

Today’s tip is to get outside and pick up litter or do something kind for the planet.

I do try to pay attention when I’m walking around, and I pick up litter I see. It’s a bit of a habit when I’m in a volleyball gym as well. I do make sure my kids clean up, but others kids and parents aren’t always paying attention, so I usually end up grabbing a few things from chairs and floors.

I haven’t done this much on my property, so I took a walk around the perimeter recently, looking for trash that had blown away or torn up by dogs. I took a plastic bag with me and picked up some trash.

Posted in Blog | Tagged , , | Comments Off on Daily Coping 7 Jan 2022

Daily Coping 6 Jan 2022

I started to add a daily coping tip to the SQLServerCentral newsletter and to the Community Circle, which is helping me deal with the issues in the world. I’m adding my responses for each day here. All my coping tips are under this tag.

Today’s tip is to let someone in your life know how much you appreciate their presence.

Easy to do to for family, and something I’d recommend you do often. It’s nice to hear that your loved ones appreciate you, and I try to remember to let them know.

I don’t do enough of this with friends, but I reached out to a friend that I have lunch with periodically and let him know that I enjoy his company, whether we get together or not. I’m making it a point to try and get together more often with him this year. We used to have lunch almost every month, and I need to get back to that.

Posted in Blog | Tagged , , | Comments Off on Daily Coping 6 Jan 2022

Finding the First Day of the Year–#SQLNewBlogger

Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.

While working on the question from Monday, I had to do a bit of date math. I remember this blog post from Lynn Pettis, and every new year I think of it.

I decided to decode the question a bit and work through the T-SQL myself as a good exercise for explaining what happens.

Here’s the code (setup and query):

CREATE TABLE dbo.Resolution
( ResolutionDate DATETIME
, ResolutionText VARCHAR(200)
)
GO
INSERT dbo.Resolution
(
     ResolutionDate,
     ResolutionText
)
VALUES
   ('2020-01-01 0:00', 'Do not travel by airplane this year'),
   ('2021-01-01 0:00', 'Go on vacation on a plane'),
   ('2022-01-01 0:00', 'Visit a new country')
GO
SELECT ResolutionText FROM  dbo.Resolution
WHERE ResolutionDate = DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()) , 0)

In this code, the final query is designed to find the first day of the current year. Here are a few examples:

2021-12-01 09_45_54-SQLQuery3.sql - ARISTOTLE_SQL2017.sandbox (ARISTOTLE_Steve (56))_ - Microsoft SQ

How does this work? Let’s decode things.

Digging Into the Algorithm

Let’s start with a simple thing. I use a 0 for a parameter in the DATEADD and DATEDIFF. What does that mean? Well, let’s go with the YEAR() function. If I use a 0 there, I see the base year in SQL Server, which is 1900.

2021-12-01 09_47_42-SQLQuery3.sql - ARISTOTLE_SQL2017.sandbox (ARISTOTLE_Steve (56))_ - Microsoft SQ

This doesn’t mean I can’t use other years, but this is the basis for calculations. What if I add to this? I can add one, and I see a different date.

2021-12-01 09_48_45-SQLQuery3.sql - ARISTOTLE_SQL2017.sandbox (ARISTOTLE_Steve (56))_ - Microsoft SQ

This is the key. I’ve gone from 0 to 1901-01-01-00:00:00. Let’s see the difference from this year, well last year when I wrote this, to 0.

2021-12-01 09_49_44-SQLQuery3.sql - ARISTOTLE_SQL2017.sandbox (ARISTOTLE_Steve (56))_ - Microsoft SQ

The result above shows me 121. Which makes sense. 1900 to 2021 is 121 years. Now, when I use the dateadd, and add 121 to 0, I get the first day, actually the first DATETIME moment, of the current year.

2021-12-01 09_50_41-SQLQuery3.sql - ARISTOTLE_SQL2017.sandbox (ARISTOTLE_Steve (56))_ - Microsoft SQ

I get 2021-01-01 00:00:00.

I can change the GETDATE() to any date time of any year, and this code returns the first moment of that year, essentially stripping off the other parts.

SQLNewBlogger

I was working on something and used a trick I learned from someone else. I decided to write this post, which only took about 15 minutes to write. The demo was simple, and I just broke apart the code, slowly putting each section in its own SELECT and then explaining it.

This is a good example of how to structure a blog post based on some knowledge you have and use in other work. You should try this.

Posted in Blog | Tagged , , | 2 Comments