Dengar's Blog Logo

Dengar's blog...
We will see what I post, probably will be some random tutorials

Tuesday, 10 May 2011

Some simple MySQL date-time functions

I often need the first of the month, the last of the month or how many days are in the month for reporting and forecasting purposes.

You can, of course, like myself in the past look up how these things are done every time you need them. But this gets frustrating and it's often easier to surround yourself with your set of own SQL-functions that give you what you need and are easy to remember.

For this purpose I give you:

  1. First of the month date:
  2. drop function if exists fn_getFirstOfMonth;
    create function fn_getFirstOfMonth(date_ datetime) returns datetime
    begin
    set @dater = date_;
    set @dater = DATE_FORMAT(@dater ,'%Y-%m-01');
    return @dater;
    end
  3. Last of the month date:
    drop function if exists fn_getLastOfMonth;
    create function fn_getLastOfMonth(date_ datetime) returns datetime
    begin
    set @dater = date_;
    set @dater = DATE_FORMAT(last_day(@dater) ,'%Y-%m-%d');
    return @dater;
    end
  4. Days in the month:
    drop function if exists fn_getDaysInMonth;
    create function fn_getDaysInMonth(date_ datetime) returns int
    begin
    set @dater = date_;
    set @dater = day(last_day(@dater));
    return @dater;
    end

Do let me know if there are other MySQL date and time functions that you would like to know.
Happy to post them here...

Saturday, 7 May 2011

Can I have some Thetan for my sandwich? - Buying religion off the shelf religion from the street

Scientologists, although not quite often recognised, have been flogging their religion on the streets for many decades now. And why not? - Other cults and religions are doing it too. Mormons, Heavens Gate and even the Manson Family have successfully advertised their ideology through direct promotion, they know the system works.

I believe people are naturally curious, but would be more careful when they know they are being 'evaluated' by a religious cult, so to circumvent the initial resistance that they would have to overcome, Scientology doesn't advertise with it's name, in fact, nothing at their meet stand indicated that they are in any way pursuing another agenda than offering a 'free stress test' and a giant book to help you through it.

Anyways, there I was, coming out of the tube and seeing the Scientologist stand right in front of the station. I was ready to be Scientologied.

"So this device checks how stressed I am by passing an insignificant amount of electricity through my body?"
I am surprised though how many people go for the "free stress test" offered by L. Ron Hubbard's minions though. I remember the 'Churches' earlier recruitment efforts required their subjects to undergo a more detailed test, that can still be taken online. It's a fun thing to do when you have absolutely nothing to do for 16 hours of your life. Feel free to do it here.
This time I was promised that the Free Stress Test would last only four minutes.

Soon enough I was handed the handles of the E-Meter, a device that measures changes in the electrical resistance of your body and the conductance of your skin by passing a very tiny current through your body. It did take a while, talking about various levels of potentially stress inducing scenarios until my tester, through turning and twisting of various dials, managed to get the needle to swing. I think about 4 minutes, in fact. It must've helped that my hands started to get a bit sweaty, after all that does increase the conductance of my skin. The result: yes, I am stressed - what a surprise.

My antidote was purchasing the Dianetics DVD and book for the little sum of £20. Since I always wanted to have a gander, I negotiated the price down to £5 for the book only, but I am afraid I have not had the chance to flick through it. After the sale, I was of course encouraged to give my name, address and email to the lead Scientologist, but I only left my first name and an old email address that I haven't used in a long time.
Your soul is possessed by this volcano and only Tom Cruise will be able to show you the way.
I did take the book home, but I was rather surprised when I saw it sodomising actual literature, see here how it forcibly engulfs my favourite book, Cannery Row by John Steinbeck.

Bad El-Ron! Down! Leave the Cannery Row alone!
It did seem rather popular with the crowd in front of this London tube station at 8.30 in the evening. Maybe buying religion off the shelf is a huge business? Maybe I should create a religion eCommerce shop where you can create your own religion by mix and match? Eg: mix some Judaism with Buddhism, top it up with Greek Mythology and sprinkle some Heaven's Gate over it. £350,000.
See, that's the clever thing about my religion shop: the product is easy to produce and even easier to source, but if you do pay THAT kinda money, you will treasure it...