March 30, 2005

Obtain Different Portions of a SQL Datetime Field

SQL has the habit of displaying date fields as: yyyy-mm-dd 00:00:00.000. But sometimes, you need to display just the Date or just the Time from a date field. Here are some of the more common, alternate formats: CONVERT(CHAR,CURRENT_TIMESTAMP,20) –[ yyyy-mm-dd hh:mi:ss(24h) ]CONVERT(CHAR(10),CURRENT_TIMESTAMP,20) –[ yyyy-mm-dd ]CONVERT(CHAR(10),CURRENT_TIMESTAMP,110) –[ mm-dd-yyyy ]CONVERT(CHAR(8),CURRENT_TIMESTAMP,8) –[ hh:mm:ss

Restricting Implicit Conversion

The compiler performs implicit conversion whenever it feels the need for it. For example: class test{ public: test (int y) : h(y) {} int h;};void func (test t){ cout

Connecting to Oracle without Configuring the tnsnames.ora File

Have you ever wanted to connect to a database without dealing with Oracle’s annoying reliance on the tnsnames.ora file? The trick is to put the tnsnames information into the ODBC connection string directly, using the Data Source=… option. The following (untested) code is VB, but the concept should work in

Make Your Servlet Code Reusable

Oftentimes, you have a bit of logic or a block of code that’s repeated in all your servlets. Or you may need to check or validate the doGet() or doPost() methods before you execute either. An efficient way to do this is to implement your logic in the service() method:

Lucene: Add Indexing and Search to Your Web Apps

ucene is one of the bright lights in the world of open source software: an industrial-strength package that many companies use for many diverse purposes. I have been using it for three years to add indexing and search capabilities to my Java applications, although Lucene technology is now available for

Change the Tab Order of the Controls in a Dialog Box

You can change the tab order of the controls in your dialog box by changing the Z order of the controls. You simply use the SetWindowPos API function. For example, suppose you want to change the tab order of controls from A, B to B, A: HWND hPrevA = GetNextWindow(A,