Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bad Date formate String because of null values?

Status
Not open for further replies.

Jeremiah31

Programmer
Nov 7, 2006
31
0
0
US
I have a date column in Excel where some of the row values have null values.

I'm using Crystal reports XI. When I apply this code to find the number of days between two dates, I receive an error message with column {Sheet1_.StoreCheckIn} being a Bad Date formate String. I open the excel sheet and made sure the column is formated as a short date value. I think the error is caused by the null values. Can someone help me out?

Local DateTimeVar d1 := CDATE(TOTEXT({Sheet1_.AtStore}));

Local DateTimeVar d2 := CDATE({Sheet1_.StoreCheckIn});

DateDiff ("d", d1, d2)
 
Try something like this:
Local DateTimeVar d1;
Local DateTimeVar d2;
if IsNull({Sheet1_.AtStore}) and IsNull({Sheet1_.StoreCheckIn}) then
0
else
d1 := CDATE(TOTEXT({Sheet1_.AtStore}));
d2 := CDATE({Sheet1_.StoreCheckIn});
DateDiff ("d", d1, d2)

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top