Tag: syndicated

  • 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.

  • 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.

  • Daily Coping 5 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 plan an act of kindness towards another.

    Obviously I don’t want to disclose this before I do it, but this was a good one. I had to think a bit here and decide what I should do for someone else.

    It did a small thing, but an item I think matters. My daughter was coming home from college. I usually keep her plant alive while she’s gone and it’s been a habit of mine to clean her sheets and remake her bed before she returns.

    This time I added something else. She’s gluten sensitive, which isn’t a big deal for me to cook, but I’ve gotten out of the habit of having stuff around she can eat. It’s been nearly 5 months since I’ve worried about gluten.

    I swung by the store after the gym the day she returned. I didn’t really need anything, but I grabbed some gluten free bagels and dropped them in the fridge. When she got come from the airport, she noticed and was thrilled. Gave her something for breakfast the next morning.

    A small thing, but a bit of joy that was easy to create by thinking of someone.

  • Daily Coping 4 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 set a career goal to focus on this year.

    I have to admit this one is hard. I’m in my 50s, near the end of my career. I honestly hope this is the last job that I have where I need to work. I hope I find things to keep my busy in retirement, which might be paid jobs, but I’m hoping this is my last full time, need a paycheck job.

    I do usually set some goals to help me keep working on myself, but seeing this as a “career goal” makes me think I ought to be more ambitious.

    I don’t worry or aim for too many technical skills, but I would like to get better at helping my employer do well. As a result, I’m going to set a goal this year to brush up on Oracle and learn about PostgreSQL. In doing this, I want some way to measure this, so here it is:

    • Set up a git repo with folders to SQL Server, Oracle, and PostgreSQL.
    • Create 3 pipelines that will CI changes for each platform.
    • Have a release pipeline to each platform, likely hitting a container somewhere for each platform.
    • Ensure that I can demo this and that I know enough Pl/SQL and pgsql that when I write T-SQL, I can duplicate it in the other languages.

    Not really a high bar, but something to work on this year.