Click to See Complete Forum and Search --> : YEAR-FORMAT with COleDateTime is only yy when year is <2000


E.Rudi
April 15th, 1999, 07:38 AM
A Problem with COleDateTime:

The YEAR-FORMAT with COleDateTime is only yy when
year is &lt;2000, but i need the format yyyy

For example: The Date is 14/4/99, but i need 14/4/1999.
Is the Year 2000, it is 14/4/2000.

Is the following COleDateTime Format-command okey?
strRet = COleDateTime(var).Format(LOCALE_NOUSEROVERRIDE, LANG_USER_DEFAULT);

My coding:

CDaoRecordset rs(& pDoc-&gt;m_TaxDB);
...
COleDateTime dateTime;
CString str;
COleVariant var;
...
rs.Open(&qd, dbOpenSnapshot, dbReadOnly);
...
str = GetStringfromVariant (rs.GetFieldValue(field));
...

//-----------------------------------------------------------------------------
CString CExampleView::GetStringfromVariant(const COleVariant& var)
{
strRet = _T("");
COleVariant varT = var;

switch(var.vt){
case VT_DATE:
strRet = COleDateTime(var).Format(LOCALE_NOUSEROVERRIDE, LANG_USER_DEFAULT);
break;
.
.
.
...
//-----------------------------------------------------------------------------

Marc Howe
April 25th, 1999, 09:23 PM
You probably know this, but I thought I should try. Look up Format in the MSDN.

Good Luck,
Marc