Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Displaying Invalid Dates
kpelzer29
I would like to create a BIRT report to display invalid dates in the database. If a date is entered with an extra digit, for example 2/9/22010 (instead of 2/9/2010) and I try to convert the value to a Date data type in the SQL query and preview the data set, the following error message box pops up in BIRT:<br />
<br />
<em class='bbc'>Cannot execute the statement.<br />
SQL error #1:Arithmetic overflow error converting expression to data type datatime.</em><br />
<br />
If I remove the SQL to convert the value to a Date and instead just return the value for the date, I do not get an error message and a string is returned such as "7344701".<br />
<br />
Is there a way I can display the value in the field as a formatted Date so the reason for date being invalid will be recognizable to someone viewing the report (for example, 2/9/22010) instead of a series of numbers like "7344701"? Thank you!
Find more posts tagged with
Comments
mwilliams
It appears that that number is the number of days from the default date if you did new Date(0,0,0). So, if you took your number that's returned and put it in the days slot in the new Date() function, like:
new Date(0,0,yourNumber), you just might get your date.
kpelzer29
Hi mwilliams,<br />
<br />
Thank you for your suggestion! I first created a computed column using the new Date() function you described below and found the default date is Dec 31, 1899. I am using SQL Server 2005 as the database where the dates are stored and the default date for SQL Server is Jan 1, 1901. The difference between the two dates is 366 days, so if I add 366 to the number returned from the database, I can display the date in a way recognizable to someone viewing the report. <br />
<br />
For example,<br />
new Date(0,0,yourNumber + 366)<br />
<br />
Thank you so much for your help!<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="95558" data-time="1328843521" data-date="09 February 2012 - 08:12 PM"><p>
It appears that that number is the number of days from the default date if you did new Date(0,0,0). So, if you took your number that's returned and put it in the days slot in the new Date() function, like:<br />
<br />
new Date(0,0,yourNumber), you just might get your date.<br /></p></blockquote>
mwilliams
I noticed it was a little off, if the number was the one returned for the date you gave, but I figured it was something like that.
Glad it worked!