Spent some time today working with DATEDIFF, DATE_ADD and all kinds of horrid looking code before realising that to do a MySQL query to get records where the date is in the past or the next x months all I need is the following.
WHERE t_position_cstm.review_date_c <= DATE_ADD(DATE(now()), INTERVAL 6 MONTH)
You can change the 6 to whatever appropriate value you have, and you can change MONTH to a variety of other values, for me the two I used today was MONTH and DAY.
I’m using this on a SugarCRM MySQL database with a custom module of Position (the actual table name is t_position).
Dave Winer on the ‘pulse of Apple’ . Makes sense. Makes me think “what is the pulse of company I work for?”.
Michael Sliwinski has relaunched the Productive Magazine . Loving the new format, and excited to hear that it’s now going to be regular each month. I can recommend you go get it, I’ve learnt something from each edition so far.
photo credit: Rak Tia via photopin cc
Too much tension, we snap.
Too little tension, we don’t perform.
The key is finding the right tension.
photo credit: Lucas Boesche via unsplash
Off-topic, well, on topic, or both maybe: I’m finding it useful to write these ‘open loops’ as it’s just a bunch of links that I want to come back to, without losing them. Quite frankly it’s easier to find them here on my blog than anywhere else. I am the intended reader of these posts, but do let me know if your find them useful at all.
photo credit: MOLLYBLOCK via photopin cc
In SugarCRM we oft record a persons birth date (in the field birthdate). Sometimes it’s useful to know how old this person is. So we create a new field age_c (note: this can be of field type Integer or Decimal) and then using this formula we can see how old they are:
If you use a Decimal field type you can remove the floor() portion of the formula so that it doesn’t round it down. This means you will see just how old they are to a decimal point. Personally I tend to prefer just knowing that they are 21 or 42 rather than 21.45 or 42.01.
photo credit: Fouquier ॐ via photopin cc
I’ve often got cause to make fields in SugarCRM (Professional and Corporate editions) to only appear based on the value of another field. We can do this easily using SugarLogic in Studio using this ‘dependant’ formula:
However today I need to make this particular field visible if the field it is dependant on is one of a few values. Thusly a different ‘dependant formula is required:
Hat tip to Anton in Sugar Support for pointing to the ‘isInList()‘ instead of trying to build something with nested ifElse()’s.
I’ve got a few things I don’t want to lose track off, open loops you could say. So rather than keeping my browser tabs open, I’m going to simply put the links here:
That’s all for now :)