Working with date/time values includes the following:
Lets say we want to update date/time field named FDATETIME from table named TEST with the value of October 6, 2000 19:00:00.
As usual, the first thing to do is to create the objects.
SACommand cmd(&Connection, "Update TEST set FDATETIME = :1");
Next step is used to actually bind the date/time value into input variable:
2000 /*year*/, 10 /*October*/, 6 /*day of month*/,
19 /*hours*/, 0 /*minutes*/, 0 /*seconds*/);
or (using C struct tm):
extern struct tm some_tm_Value;
SADateTime dtValue = some_tm_Value;
or (using Windows DATE data type):
extern DATE some_DATE_Value;
SADateTime dtValue = some_DATE_Value;
Next line binds date/time value.
cmd << dtValue;
All that we need now is to execute a query:
Lets say we want to retrieve date/time field named FDATETIME from table named TEST.
As usual, the first thing to do is to create the objects:
SACommand cmd(&Connection, "Select FDATETIME from TEST");
For more information see Connecting to databases.
Next thing to do is to execute a query:
Next step is used to actually fetch the row and access date/time data:
if(cmd.FetchNext()) // or while(cmd.FetchNext())
SADateTime dtValue = cmd.Field("FDATETIME");
// access through standard C struct tm
struct tm tmValue = dtValue;
struct tm tmValue2 = (struct tm)cmd.Field("FDATETIME").asDateTime();
// access through Windows DATE data type
DATE dateValue = dtValue;
DATE dateValue2 = (DATE)cmd.Field("FDATETIME").asDateTime();
If you haven't found the answer to your questions or have some problems using the Library, please, send an e-mail to firstname.lastname@example.org