Date Math Annoyances In SQL Server Queries

แชร์
ฝัง

ความคิดเห็น • 13

  • @alexandermayerkirstein
    @alexandermayerkirstein หลายเดือนก่อน +1

    Recounting your takeaway points at the end was highly appreciated. Helps solidify your content in mind.

  • @douglascoats7081
    @douglascoats7081 หลายเดือนก่อน +2

    In this episode Master Sorcerer Erik Darling demonstrates his mastery of time. He also puts on his robe and wizard hat.

    • @ErikDarlingData
      @ErikDarlingData  หลายเดือนก่อน

      Just don’t call me Dr. Whom.

  • @cartercordingley6062
    @cartercordingley6062 หลายเดือนก่อน +1

    I don't really like using the datediff function for this.
    Sometimes, I'll use
    Where datevalue1 between dateadd(month,-12,datevalue2) and datevalue2 instead. But make sure both are the same date type.

  • @FlaggedStar
    @FlaggedStar หลายเดือนก่อน

    00:26 I am increasingly convinced that Erik Darling is a 4chan poster.

  • @markk8104
    @markk8104 หลายเดือนก่อน

    Oracle: date - interval '1' month. Oh that produces invalid dates. Was confusing in March when it tried to find the 30th Feb.

    • @ErikDarlingData
      @ErikDarlingData  หลายเดือนก่อน

      Ooh I remember running into that trying to produce sample data in Oracle! Quite frustrating!

  • @stephenlawrenson2380
    @stephenlawrenson2380 หลายเดือนก่อน

    Same with manipulating any field value. Just had a quick win where they were using
    Col1 +Col2 = parameter. Replaced with
    Col1 = Left(param,2) and Col2 = Right(param, Len(param)-2). A couple of other bits and now runs is 0 seconds.
    Quick Q - I had to change the param type to VARCHAR from CHAR as in one scenario (**default) it would return 0 but the other 30k+ scenarios it matched. Why would that be?? Ta

    • @ErikDarlingData
      @ErikDarlingData  หลายเดือนก่อน +1

      Perhaps a strange implicit conversion? Hard to say without an example.

  • @adrian_sanchez
    @adrian_sanchez หลายเดือนก่อน

    This is not a dumb discussion.... the datediff function is disappointing. I was hoping you had a clearcut alternative but i see that we are all in the same boat...At my shop, we do a lot of 1-3 year date comparisons so I always have to remember to date compare with the dateAdd function instead. On microsoft's end, it seems that this could all be fixed with a simple change of the the field type. DATEDIFF(YEAR, '07/12/2024', '07/11/2025') returning ~0.99 instead of = 1 seemed like it would solve "most" of the frustration.

    • @ErikDarlingData
      @ErikDarlingData  หลายเดือนก่อน

      That’s an interesting idea! It can be quite a hassle to check for accurate differences with tiny units.