Excel - Age Formula

Formula to calculate Age using a Date.

=INT((TODAY()-Date of Birth)/365.25)

DOS Date Formatting

One of my collegue was writing a DOS script that creates directories with date and archives files. The problem she faced is with the DATE command in DOS. DATE command gives date in mm/dd/yyyy format. If we use the same string for creating directory MKDIR command creates 3 directories with mm, dd and yyyy as nested directories.

C:\>echo %DATE%
Wed 03/26/2008

After some search we finally used the Substring methods in DOS to arrive with DATE format mm-dd-yyyy.

C:\>echo %date:~4,2%-%date:~7,2%-%date:~10,4%
03-26-2008

Explanation (%date:~4,2%)
% is used to enclose the expression
:~ is used to start the substring operation
4 is start index
2 is no of characters to extract

PC - Open Ports

Today I found the following command very very useful. I have a DB2 database running locally and I have no problem connecting to it using DB2 Control Center. But when I use Aquadata studio.. ADS requires the port number to connect to... which I dont know and DB2 Control Center does not tell.

So I needed a command to see what all ports my PC had opened. And the following command came to my rescue.

netstat -an | find /i "listening"

Replace dot with comma

We have a requirement in our web application to replace the dot pressed in the Numeric pad, with comma. I 've searched in the internet for a solution for this and could not find one.
Hence I had to find the following solution. (Works only in IE browser)

var dotReplace = false;
function keypressEvent(the_key) {
if(the_key == 46 && dotReplace) {
event.keyCode = 44;
}
}
function keydownEvent(the_key) {
if(the_key == 110) {
dotReplace = true;
} else {
dotReplace = false;
}
}


And in the form call the above functions for respective events.
<input name="disp" type="text" 
onkeypress="keypressEvent(event.keyCode)"
onkeydown="keydownEvent(event.keyCode)">

Working Example:
Type a dot from the numeric pad here: