browse by category or date

At the beginning of every month, my Ops executive colleague always send me email, asking for a report on jobs carried out last month. I would then open up my Oracle Developer window, run query, export the result to Excel, then mail it back to him.

The query look something like this:

select *
from TBL_Job
where CreateDate >= to_date('01 Feb 2015', 'DD MON YYYY')
and CreateDate < to_date('01 Mar 2015', 'DD MON YYYY')

I've been thinking of moving this report to our Jasper Server. This way I can schedule the report to run, then automatically mail the result in Excel format. In order to do that, I need to change the query. And that's where the TRUNC function comes to shine.

Trunc (short for truncate), will strip any extra value from a DateTime type. You can think of it as Floor (round-down) function for a DateTime type.

E.g. If you just apply Trunc to a DateTime, it will strip away the Time value.

select Trunc(sysdate) from dual; 
--Output: 13-MAR-2015 00:00:00

You can also specify how far the truncation will go

select Trunc(sysdate, 'MONTH') from dual; 
--Output: 01-MAR-2015 00:00:00

Other useful examples of Trunc:

-- First day of this year
select trunc(sysdate, 'YEAR') from dual; 
-- Output: 01-JAN-2015 00:00:00

-- First day of this quarter
select trunc(sysdate, 'Q') from dual; 
-- Output: 01-JAN-2015 00:00:00

-- First day in the quarter of 18 Aug 2015
select trunc(to_date('18 AUG 2015','DD MON YYYY'), 'Q') from dual; 
-- Output: 01-JUL-2015 00:00:00

-- First day of this week
select trunc(sysdate, 'W') from dual; 
-- Output: 08-MAR-2015 00:00:00

With this information, we can replace the original query

select *
from TBL_Job
where CreateDate >= trunc(trunc(sysdate, 'MONTH')-1, 'MONTH')
and CreateDate < trunc(sysdate, 'MONTH')

This way, at any time we run the query, it will always return last month data.

I hope it helps,
Cheers

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant:

I write really slow. My recent post about Buying CPU Cooler took few days to complete (I bought and installed Corsair H60 on March 3rd). I want to improve this. As we all know, it’s difficult to drastically change habit. What we should do, should be in small iterations and consistency.

So here’s my small steps:

  1. Write everyday. Yes, I’ll produce a lot of bad writings, hopefully I’ll get better, eventually.
  2. I will add tag, to indicate how much time I spent completing the post.

And this, is my New Year’s resolution 😀

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant:

Recently I realized that my home PC is overheated. It frequently restart by itself, then halted with the BIOS showing CPU temperature error. BIOS’ hardware monitor shows that the CPU temperature is ranging between 90° to 100° Celsius. Yet, I’m still unconvinced about it.

To find out the actual CPU temperature, I installed Hardware Monitor. In normal operation with no programs running in the foreground, the CPU temperature was ranging between 70-80° Celsius. On heavy operation, like simultaneously open few projects in Visual Studio 2012 the temperature frequently hit 100° Celsius.

I become really really worried when I read Intel’s product page. It states that the T-Case (the maximum temperature allowed at the processor Integrated Heat Spreader) is 67.9° Celsius. It means any temperature beyond 67.9° will shorten the lifespan of my CPU.

I quickly open Fuwell’s website and open up their price-list. Since I’m currently using the stock CPU Cooler, I guessed that Liquid CPU cooler is the obvious replacement.

Fuwell’s prices for CPU Cooler (Feb 2015)

I immediately fell to Antec Kühler for it’s German name. No lousy products have ever come out from German engineering culture. Since Antec Kühler comes in three prices, I just choose the mid-price:


Antec Kühler H20 950

Considering that I have no prior experience in installing liquid CPU Cooler (and I generally sucked at hardware), I went to YouTube for wisdom. Alas, there’s no installation guide for KÜHLER H2O 950. Instead, I found the installation guide for KÜHLER H2O 920. I kind of guessed that 920 and 950 will not be significantly different. Thus, I continue to watch the video till the end.

Eventually I found out that 920 and 950 are significantly different.

Because of the DIY video, I had a second thought. When I reached Fuwell’s main shop at Sim Lim Square level 4, I am no longer interested with Antec Kühler H20 950 for two reasons:

  1. The liquid on 950 go through the fan as well as the radiator. So if the fan stopped working, we can’t replace it with any custom fan.
  2. The air direction in 950 is fixed, in-out. I don’t think this is good idea because the air inside the casing is already warm. So the cooling process won’t be optimum

So I returned to the price list looking for product with similar price range. The brand that immediately stuck to my brain was Corsair. I don’t recollect any complaints about this brand. Furthermore, look at those sails… Yarrrr.. shiver me timber… (FYI: I love pirates! 😀 ) Thus, I was leaning towards Corsair Hydro H60:


Glorius sails …

After reading the reviews at Amazon, I’m sold. I picked up one unit, paid it at the cashier, then eagerly went home. The installation process is actually not complicated (after you watch above video). But I need to do some extra works:

  1. Cleaning up. My PC has collected many dust. Even my GPU’s heatsink is clogged with dust.
  2. Cleaning the thermal paste residue. After taking out my stock CPU cooler, I had thermal paste residue blotted on the CPU. So I used Alchol 70% and paper towel to clean it up
  3. My ATX casing is from older generation. To install the backplate (to hold H60 firmly), I need to detach my motherboard from the casing.

It took at least two hours for me to complete the whole process. Luckily, I got the result that I want.

Under normal load

Under 100% Load

Conclusion

  • Don’t buy product because of “German engineering myth“, nor your affinity to Pirates 😀 (in this case, Pirates win, yayy)
  • If you can’t find the DIY installation guide of a product in YouTube, consider other brands which have (in this case, 920 is proven to be better than 950)
  • Don’t disassemble your PC when your 3-years-old daughter is still awake. You’ll have an “assistant” from hell. My very own “assistant” was persistently insist to help me. At one time, she dropped the screw driver inside the casing with me watching in horror (T_T)

I guess that’s all, I hope it helps.
Cheers 😀

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Possibly relevant: