![]() ![]() If this is all too much to remember, I totally understand.įor a cheat sheet of important date calculations, see Tim Ford's article.įor a calendar table of important dates, see Aaron Bertrand's article. We should use this format where possible for the relative dates (like 'last 30 days'), but some other ranges may require our own custom URL. The URL should support elasticsearch's date math. DATEADD(DAY, DATEDIFF(DAY, 0, GETUTCDATE()), -30) We should add more relative date ranges for common ranges, like YTD, this fiscal quarter, last fiscal quarter, last fiscal year, and maybe others. ![]() The second part does the same thing, except subtracting 30 days from, at 0 hours. That gives us the very start of the current day, at 0 hours. Is the adding the number of days between and current to. Which means the full expression: SELECT DATEADD(DAY, DATEDIFF(DAY, 0, GETUTCDATE()), 0) That gives us the number of days between and the current date. Let's look inside our original query: SELECT DATEDIFF(DAY, 0, GETUTCDATE()) This will bring back 00:00:00.000, which is the same thing as this: SELECT DATEADD(DAY, -1, '19000101') AS Which means that you can convert nearly any number to a date. SELECT DATEDIFF(DAY, 0, GETUTCDATE()) AS ,ĭATEDIFF(DAY, '19000101', GETUTCDATE()) AS In date math, the number 0 and the date are interchangeable. ![]() On this particular day, it returns 19:34:20.050. Start with this: SELECT GETUTCDATE() AS utc_date Next post Previous post Final thoughts on switching from TextExpanderīack in April, I wrote a few posts on switching from TextExpander to Keyboard Maestro as my snippet expander (I was already using Keyboard Maestro for other things).The best way to understand how date math works is to break a query down into its parts. Now that I have a couple of months of this new system under my belt, I thought it was worth a followup post. I won’t recapitulate the changes in TextExpander that prompted me to make the change-you can read those old posts for that-other than to say that Smile’s later reduction in price for TextExpander didn’t persuade me to stay with it. I agree with Gabe’s sentiments, both before and after the price change. Moving my TextExpander snippets to Keyboard Maestro was relatively painless, thanks to Ryan M’s excellent migration script. The only snippets that had to be redone by hand were my date and time stamp snippets and those that used TextExpander’s fill-in feature. The date and time snippets were easy to rewrite. Keyboard Maestro uses ICU formatting strings instead of the more familiar (to me) strftime-inspired formatting codes in TextExpander, but it wasn’t hard to translate. And I had only a handful of them, anyway. Snippets that used fill-in fields were rewritten to make use of Keyboard Maestro’s Prompt for User Input action to save a string to a variable that’s later included in the text output. There are pros and cons to this approach. TextExpander’s fill-ins have the advantage of letting you see your input in the context of the rest of the snippet, but Keyboard Maestro’s prompt dialog is more compact, especially when the snippet as a whole includes a lot of boilerplate text with only a few variable parts. I’ve found no significant difference in using Keyboard Maestro instead of TextExpander. I don’t have hundreds or thousands of snippets, only dozens, so I haven’t run into any of the problems Peter Lewis, Keyboard Maestro’s developer, has warned about. The snippet expansion is plenty speedy for me. There’s no question, though, that TextExpander is distinctly faster at making new text-only snippets, mainly because it has special commands for doing so. Since I don’t make new snippets very often, this isn’t an important consideration for me, but it might be for you. I did, by the way, investigate both TypeIt4Me (which I used many years ago) and Typinator as TextExpander substitutes instead of Keyboard Maestro. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |