Subject | What C++ datatype can be used to store DATE ? |
---|---|
Author | ritchie72nlnl |
Post date | 2003-12-21T15:43:44Z |
Hello,
Is there a suitable datatype in C++ (with MFC) to store data from SQL
datatype DATE?
I have tried to use COleDateTime, which worked perfectly for updating
the database, but doesn't seem to work the other way around.
I will post some of the code to illustrate the problem:
/// Code Snippet ///
void ShowDate()
{
COleDateTime dtBirthday;
CString sBirthday;
CMyRecordset myRecordset;
myRecordset.Open();
while (!myRecordset.IsEOF())
{
dtBirthday = rst.m_BIRTHDAY;
sBirthday = dtBirthday.Format(VAR_DATEVALUEONLY);
MessageBox("Birthday is " + sBirthday, "Result");
myRecordset.MoveNext();
}
myRecordset.Close();
}
/// End of code snippet
This code compiles without errors or warnings, but the messagebox
will say "Birthday is Invalid DateTime."
My guess is I have to use another datatype, but which one?
Thanks in advance,
Richard
Is there a suitable datatype in C++ (with MFC) to store data from SQL
datatype DATE?
I have tried to use COleDateTime, which worked perfectly for updating
the database, but doesn't seem to work the other way around.
I will post some of the code to illustrate the problem:
/// Code Snippet ///
void ShowDate()
{
COleDateTime dtBirthday;
CString sBirthday;
CMyRecordset myRecordset;
myRecordset.Open();
while (!myRecordset.IsEOF())
{
dtBirthday = rst.m_BIRTHDAY;
sBirthday = dtBirthday.Format(VAR_DATEVALUEONLY);
MessageBox("Birthday is " + sBirthday, "Result");
myRecordset.MoveNext();
}
myRecordset.Close();
}
/// End of code snippet
This code compiles without errors or warnings, but the messagebox
will say "Birthday is Invalid DateTime."
My guess is I have to use another datatype, but which one?
Thanks in advance,
Richard