October 28, 2017 at 11:28 am
Comments posted to this topic are about the item Which is the end?
October 28, 2017 at 2:10 pm
I still think it hilarious (I laughed almost hysterically when I first heard of it) , in a dreadful sort of way, that they took the time to create a function to return the final date of any given month but nothing explicit to find the first of the month. If they had, especially with the optional parameter, they wouldn't have actually needed an EOMONTH function and we wouldn't have to explain to folks why they shouldn't use BETWEEN for temporal range criteria. π
--Jeff Moden
Change is inevitable... Change for the better is not.
October 29, 2017 at 11:19 pm
Nice question to start the week on, thanks Steve
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
βlibera tute vulgaris exβ
October 30, 2017 at 1:16 am
Nice question Steve. Thanks for being easy on start of the week π
October 30, 2017 at 6:32 am
It's a nice function that fills a hole, but one I've always used the first day of the next month minus 3 ms to include the time. I guess EOMONTH's return date could be converted to a datetime. I'll admit I'm curious about the performance differences. I'll do some testing after I get caught up with work. It's on the list; it might even be fun. :hehe:
October 30, 2017 at 8:50 am
Jeff Moden - Saturday, October 28, 2017 2:10 PMI still think it hilarious (I laughed almost hysterically when I first heard of it) , in a dreadful sort of way, that they took the time to create a function to return the final date of any given month but nothing explicit to find the first of the month. If they had, especially with the optional parameter, they wouldn't have actually needed an EOMONTH function and we wouldn't have to explain to folks why they shouldn't use BETWEEN for temporal range criteria. π
I guess that it's because every month starts at the 1st, but the end can vary from month to month and sometimes depending on the year.
However, I do agree that your proposed function would be given a better use.
October 30, 2017 at 4:31 pm
Ed Wagner - Monday, October 30, 2017 6:32 AMIt's a nice function that fills a hole, but one I've always used the first day of the next month minus 3 ms to include the time. I guess EOMONTH's return date could be converted to a datetime. I'll admit I'm curious about the performance differences. I'll do some testing after I get caught up with work. It's on the list; it might even be fun. :hehe:
Heh... ok... so you're one the folks I may have to explain the BETWEEN thing to. π
--Jeff Moden
Change is inevitable... Change for the better is not.
October 30, 2017 at 8:00 pm
Jeff Moden - Monday, October 30, 2017 4:31 PMEd Wagner - Monday, October 30, 2017 6:32 AMIt's a nice function that fills a hole, but one I've always used the first day of the next month minus 3 ms to include the time. I guess EOMONTH's return date could be converted to a datetime. I'll admit I'm curious about the performance differences. I'll do some testing after I get caught up with work. It's on the list; it might even be fun. :hehe:Heh... ok... so you're one the folks I may have to explain the BETWEEN thing to. π
EOMonth is badly named, I think. After all, the end of the month and the data of the last day of the month are not the same thing. For example the last day of October 2017 is 2017-10-31 but the end of he month October 2017 occurrs at 2017-11-01T00:00:00, a tatetime (or datetime2) not a date.
And the reason that "between" doesn't go well with datetime2 (or datetime) is that it's a pain in the but to have to think (and type) 2017-10-31T23:59:59.9999999 (or 2017-10-31T23:59:59.997) or a different number of 9s after the stop for datetime2 with non-default precision (eg datetime2(5) would need five 9s after that decimal point instead of the 7 for datetime2 with default precision (which is datetime2(7)). Personally I find it a pain in the butt to have to write "B <= D and D < E" instead of the usual math notation "B <= D < E" but most programming languages are pretty horrible so I put up with it (and there's no way i'm going to write all those 997s or strings of 9s just so I can use use "between"); and I also imagine that all hell can break lose if someone decides that they want to hold more precise times so that instead of datetime2(2) something is changed to datetime2(3) and as a result every use of "between" has to be changed (because somewhere in something there's a between where the 9s count won't be changed wlthough thy should have been and other places where they count was got right, potentially leading to mutually inconsistent reports being generated.
Tom
October 31, 2017 at 5:40 am
Jeff Moden - Monday, October 30, 2017 4:31 PMEd Wagner - Monday, October 30, 2017 6:32 AMIt's a nice function that fills a hole, but one I've always used the first day of the next month minus 3 ms to include the time. I guess EOMONTH's return date could be converted to a datetime. I'll admit I'm curious about the performance differences. I'll do some testing after I get caught up with work. It's on the list; it might even be fun. :hehe:Heh... ok... so you're one the folks I may have to explain the BETWEEN thing to. π
Probably not. I get the way it works and already do the >= and < consistently in the WHERE clause. I was wondering about the performance differences in calculation using the new EOMONTH function, adding a day and subtracting 3 ms to obtain the same datetime value as I use now. Given the performance of some newer functions, I'm interested in what I'll find with this one.
October 31, 2017 at 7:59 am
Ed Wagner - Tuesday, October 31, 2017 5:40 AMJeff Moden - Monday, October 30, 2017 4:31 PMEd Wagner - Monday, October 30, 2017 6:32 AMIt's a nice function that fills a hole, but one I've always used the first day of the next month minus 3 ms to include the time. I guess EOMONTH's return date could be converted to a datetime. I'll admit I'm curious about the performance differences. I'll do some testing after I get caught up with work. It's on the list; it might even be fun. :hehe:Heh... ok... so you're one the folks I may have to explain the BETWEEN thing to. π
Probably not. I get the way it works and already do the >= and < consistently in the WHERE clause. I was wondering about the performance differences in calculation using the new EOMONTH function, adding a day and subtracting 3 ms to obtain the same datetime value as I use now. Given the performance of some newer functions, I'm interested in what I'll find with this one.
Just pulling your chain because you mentioned the -3ms thing. π My thought was, "Will the real Ed Wagner please stand up"?
--Jeff Moden
Change is inevitable... Change for the better is not.
October 31, 2017 at 8:51 am
Jeff Moden - Tuesday, October 31, 2017 7:59 AMEd Wagner - Tuesday, October 31, 2017 5:40 AMJeff Moden - Monday, October 30, 2017 4:31 PMEd Wagner - Monday, October 30, 2017 6:32 AMIt's a nice function that fills a hole, but one I've always used the first day of the next month minus 3 ms to include the time. I guess EOMONTH's return date could be converted to a datetime. I'll admit I'm curious about the performance differences. I'll do some testing after I get caught up with work. It's on the list; it might even be fun. :hehe:Heh... ok... so you're one the folks I may have to explain the BETWEEN thing to. π
Probably not. I get the way it works and already do the >= and < consistently in the WHERE clause. I was wondering about the performance differences in calculation using the new EOMONTH function, adding a day and subtracting 3 ms to obtain the same datetime value as I use now. Given the performance of some newer functions, I'm interested in what I'll find with this one.
Just pulling your chain because you mentioned the -3ms thing. π My thought was, "Will the real Ed Wagner please stand up"?
Ahhh - I see it now. Touche. Honestly, Jeff, I'm just looking for excuses to test the new functions to see if they perform anything like the old ones. π
Then again, I need to have the time to do it, which I haven't yet, but I will eventually...or at least I hope to.
November 2, 2017 at 7:19 am
One problem with EOMONTH is that it doesn't return the time, and if you convert the date to datetime, you will not get the end of month as the time will be 00:00:00 and not 23:59:59.
It works for equality operations on dates, but not datatime.
/HΓ₯kan Winther
MCITP:Database Developer 2008
MCTS: SQL Server 2008, Implementation and Maintenance
MCSE: Data Platform
November 2, 2017 at 11:53 am
hakan.winther - Thursday, November 2, 2017 7:19 AMOne problem with EOMONTH is that it doesn't return the time, and if you convert the date to datetime, you will not get the end of month as the time will be 00:00:00 and not 23:59:59.
It works for equality operations on dates, but not datatime.
23:59:59 is not the end of the month either. 23:59:59.997 is (assuming DATETIME data type). You should never be using equality (closed) for datetime intervals. You should always use half-closed intervals.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply