Page 1 of 1

check datetime field null value or blank value

Posted: Fri Aug 20, 2010 7:29 am
by Vikas
Hi

FinalDuration field datatype is datetime in access database. In table few rows are blank without data. I am using the below formula to calculate the field value.

Hour(DownloadTourMaster.FinalDuration) * 3600 + Minute(DownloadTourMaster.FinalDuration) * 60+ Second(DownloadTourMaster.FinalDuration)

but in database table few rows are blank without data. so its displaying the runtime error
Null referenece as Object reference not set to an instance of an object.

So I need to write a check condition so that if field is blank , its not calculate the field value.

Please help me.

Thanks
Vikas

check datetime field null value or blank value

Posted: Fri Aug 20, 2010 7:39 am
by Ivan
Hello,

Can you please send us a sample report with data, which reproduces the issue?

Thank you.

check datetime field null value or blank value

Posted: Fri Aug 20, 2010 7:55 am
by Vikas
Hi Ivan

Issue is that if in database table are missing few records in finalduration column then runtime error is coming.

I want to check that if row does bot have the data in particular row , in that case its not show thw error. So i need to implement a IF condition.

Please see the attachment throuigh my first post.

Please suggest

Thanks
Vikas

check datetime field null value or blank value

Posted: Mon Aug 23, 2010 1:30 am
by Alex K.
Hello,

Use the following code:
Hour(DownloadTourMaster.FinalDuration.GetValueOrDefault()) * 3600 + Minute(DownloadTourMaster.FinalDuration.GetValueOrDefault()) * 60+ Second(DownloadTourMaster.FinalDuration.GetValueOrDefault())
Thank you.