Author Archives: Nicolas Riousset

Monetdb : how to convert a string to a timestamp ?

Monetdb is great tool, with a not so great documentation… Converting a string/varchar to a timestamp is easy once you know the proper function to call.

The time conversion functions are listed in the [Monetdb installation folder]\MonetDB5\lib\monetdb5\createdb\13_date.sql file :
[code lang=sql]
create function str_to_date(s string, format string) returns date
external name mtime.”str_to_date”;

create function date_to_str(d date, format string) returns string
external name mtime.”date_to_str”;

create function str_to_time(s string, format string) returns time
external name mtime.”str_to_time”;

create function time_to_str(d time, format string) returns string
external name mtime.”time_to_str”;

create function str_to_timestamp(s string, format string) returns timestamp
external name mtime.”str_to_timestamp”;

create function timestamp_to_str(d timestamp, format string) returns string
external name mtime.”timestamp_to_str”;
[/code]

The syntax of the format string follows the MySQL one.

And eventually, here is a conversion example of a varchar to a timestamp
[code lang=sql]
select str_to_timestamp(‘2016-02-04 15:30:29’, ‘%Y-%m-%d %H:%M:%S’);
[/code]

How to import data from MySQL to SQL Server 2014 ?

Importing data from one database engine to another is often a pain. Getting the data out of MySQL is easy, but pushing it to SQL Server may be harder. The easiest way to achieve this is to use “SQL Server Import and Export Wizard” to directly query your MySQL Database, and push the data in your SQL Server.

Trying other techniques often leads to a waste of time. For example, Continue reading

Form layout manager for C++ Builder 6

You have a C++ builder application, with some complex forms, and you’d like them to properly react to window resizing.
You heavily used anchors and alignment, but reached the limits of these features. For example, as soon as you have 3 controls in a row and that your form is resized, you can’t get them to grow proportionaly. If some controls must sometimes be hidden, you can’t get their neighbours to automatically shift to fill the holes.
Dealing with these situations manually is painful and costly, you miss Java layouts.

There’s no builtin features solving these problems in older versions of C+ Builder (<= 6), but you might find helpful my GitHub CppBuilderFormLayoutDemo project, which contains a couple of classes inspired from Java Layout Managers, along with a C++ Builder 6 demo project.

demo-layout
Continue reading

Using WM_SETREDRAW to prevent window flickering

Flickering is a common issue with Windows applications. Different techniques exist to solve it, but they are more or less intrusive, and more or less efficient. Double-buffering for example is probably the best solution, but hard to put in place in a legacy code (even impossible sometimes). Using the WM_SETREDRAWmessage can be a light and efficient solution. Continue reading