MySQL: Selecting all records for the previous month.

I had a to do a report for a client today that would get all the orders placed in the previous month and that report needs to run on the 5-th of the following month. For example, if today was 5th of March it would have to show all the orders for the month of Februrary. The problem is that each month is different 28, 29, 30, or 31 days and since I couldn’t find a quick reference by googling here is my query (stripped of all specifics) for anyone who needs to run a similar query. The trick is to use LAST_DAY() function in MySQL.

select *
from orders
where order_date
between date_format(date_sub(curdate(), interval 1 month), “%Y-%m-01″)
and date_format(last_day(date_sub(curdate(), interval 1 month)), “%Y-%m-%d”)
order by order_date asc;

P.S.: My order_date is a date field in the format 2009-01-01, check DATE_FORMAT() function in MySQL spec to match your date field format.

Enjoy

Posted in Culture, Programming / Web | Tagged | Leave a comment

How to fix c00026c error in Windows 2000.

WARNING: I make no promises that this will work for you. Do it at your own risk. You and you alone assume all resposnsibility.

Just came across this error yesterday: when one of our Win2K systems was booting up it kept giving us Blue Screen of Death and the error read: ” c000026c . Can’t read file in  SystemRoot\System32\swapk.sys ”

The only thing that could go wrong - was the virus removal we did 3 days earlier. It was that pesky “Anitvirus 2009″ spyware/virus that keeps pretending to be legitimate software. Anyways we got rid of it with AntiVira . Avg wouldn’t load properly on that machine as it requires Service Pack 4 for Win2k to run. Anyways long story short - apperently it cleaned out the everythign except for that one problem.

Read More »

Posted in Operating Systems, Technology | Tagged , , , , , | Leave a comment

Why is it essential to know you subject matter, at least sometimes.

I’m not a big fan of higher educaiton, actually I think it’s counter productive for some people. I’ve been arguing for a long time that a determined and eager person can get a better education on their own. Thankfully once in a while I come across some gems that prove my point entirely, thou in a backward sort of way.  Case in point is Preston Gralla and Computer World. It doesn’t surprise me anymore that Computer World has become an equivalent of yellow press (double pun intended) of computer industry, letting more and more trashy publications on it’s pages .But how this guy was able to become an “expert” in his field and publish more than 35 books, is beyond understanding.

An expert gives an objective view. He gives his own view.
Morarji Desai
Indian Politician

Read More »

Posted in Humor, Operating Systems, Programming / Web, Technology | Tagged , , , , , , , | Leave a comment

How to read & write to a dbf database file from ruby.

A little history. The company I work for has an old system that was written in house for a period of almost 20 years and it’s done in dBase. Once cool and allmighty, it’s not longer, dare we say, a system that is at the forefront of computer technology. It has a numerous problems, i.e. multiple users locking tables, AD based security for each individual file/table, slow, etc. Anyways long story short, we decided to convert our system to a web based one, with a Debian/Apache/Passenger/MySQL/Ruby backend - and whatever at the frontend. Read More »

Posted in Programming / Web | Tagged , , , , | 6 Comments

Если бы языки програмирования были бы машинами.

Below is my literary translation ( with some small changes and additions ) of a post on Mike Vanier’s website - If programming languages were cars. Translated and posted with author’s permission.

Ниже - мой литературный перевод заметки на сайте Майкла Ваниера, с небольшими добавлениями и немного отсебятины. Переведено и напечатано с разрешения автора.

  • Ada - это аццкий танк. Большой и толстый, времён 2-ой мировой, чем-то напоминает русский T-34 или американский Шерман М-4. Люди смеются над тобой когда ты им говоришь, что ты в танке. Но ты, блин, ещё посмеёшся над ними, когда наступит война, и они будут ездить на своих спортивных машинах по полю битвы. Хорошо смееётся тот, кто смеётся последний. Особенно если у него есть план, и он в танке. Read More »
Posted in Culture, Humor, Programming / Web, Technology | Tagged , , , , , | 2 Comments
3,632 spam comments
blocked by
Akismet