cancel
Showing results for 
Search instead for 
Did you mean: 

Saving a Datetime DataSource

Former Member
0 Kudos

Good Day

Experts:

I am having all kind of trouble trying to figure out how to save a blank Datetime datasource defined field to a SQL Server 2005 database field defined as Datetime.

When adding a record to one of our AddOn screens, several fields defined as Datetime datasource and Datetime in the database are not required to have any data(valid date) in them. Here is what I have tried using:

WOForm.Items.Item("txtCompDte").Specific.value

WOForm.DataSources.UserDataSources.Item("u_DemDue").ValueEx

The variable declared at the top of my S/P that I am calling is defined as datetime since the target field is defined as datetime.

How do I pass the data or potentially lack of data to this datetime field so I don't end up with 1/1/1900 in the table? This creates a problem since then 1/1/1900 is then shown back on the screen instead of a blank field.

Thanks for the help,

Ed

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Ed,

Basically the system will take the date as year-mm-dd. So u have to convert it. You better to try

datetime.parseexact(WOForm.DataSources.UserDataSources.Item("u_DemDue").ValueEx,"yyyyMMdd", Nothing)

If it helps give reward points,

Regards,

Anitha

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Ed,

While Inserting a Empty datetime value Check for the Empty Datetime if it is empty then pass Null value to that field.While Retrieving the datetime value Check For that null using isnull function of SQL server if it is null then Assign empty value for that field

SELECT isnull(URDATETIMEFIELD,'') FROM TABLE1.

Hope this helps

Regards

Vishnu