Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Setting DateTime field to Null

75 views
Skip to first unread message

Gagan Toor

unread,
May 13, 1998, 3:00:00 AM5/13/98
to

VC4.2 SQL Server 6.5

I have a datetime field in a table in Sql Server which is stores a date
(the field is nullable). I am able to store a date or set it to null
using a TIMESTAMP_STRUCT and the RFX_Date function provided by MFC
(using CRecordset object). However, once I store a date (e.g. 10/2/97)
in the field, I am unable to set it to null on subsequent edit
operations. I get a "invalid time" error from Sql Server. I am able to
edit and change the date, however I cannot set it to null (once a date
has been set).
I set the TIMESTAMP_STRUCT as following to set it to null:

TIMESTAMP_STRUCT m_tsDateTime;

m_tsDateTime.year = 99;
m_tsDateTime.month = 99;
m_tsDateTime.day = 99;
m_tsDateTime.hour = 99;
m_tsDateTime.minute = 99;
m_tsDateTime.second = 99;
m_tsDateTime.fraction = 99;

The above will set a datetime to null as long as the datetime field
does not have a date.

Any help will be appreciated.
Thanks
Gagan.

Glenn Brude

unread,
May 14, 1998, 3:00:00 AM5/14/98
to

I have had these problems to some times, changing my
date fields to text instead to fix that. Now I'm
rewriting my program, and believe I will have to use
ASSERT(m_pSet->IsFieldNullable(...))
m_pSet->SetFieldNull(...)
Maybe you can test if that works?
/Glenn

Gagan Toor

unread,
May 14, 1998, 3:00:00 AM5/14/98
to


It works!!!

Thanks.
Gagan

fabian.s...@gmail.com

unread,
Mar 14, 2017, 11:35:53 AM3/14/17
to
Am Mittwoch, 13. Mai 1998 09:00:00 UTC+2 schrieb Gagan Toor:
> VC4.2 SQL Server 6.5
>
> I have a datetime field in a table in Sql Server which is stores a date
> (the field is nullable). I am able to store a date or set it to null
> using a TIMESTAMP_STRUCT and the RFX_Date function provided by MFC
> (using CRecordset object). However, once I store a date (e.g. 10/2/97)
> in the field, I am unable to set it to null on subsequent edit
> operations. I get a "invalid time" error from Sql Server. I am able to
> edit and change the date, however I cannot set it to null (once a date
> has been set).
> I set the TIMESTAMP_STRUCT as following to set it to null:
>
> TIMESTAMP_STRUCT m_tsDateTime;
>
> m_tsDateTime.year = 99;
> m_tsDateTime.month = 99;
> m_tsDateTime.day = 99;
> m_tsDateTime.hour = 99;
> m_tsDateTime.minute = 99;
> m_tsDateTime.second = 99;
> m_tsDateTime.fraction = 99;
>
> The above will set a datetime to null as long as the datetime field
> does not have a date.
>
> Any help will be appreciated.
> Thanks
> Gagan.



How about:

CDatabase::ExecuteSQL and "Update" with field set to null
0 new messages