Home
Crystal Reports Training
Crystal Reports XI
Crystal Reports .NET
Crystal Reports Forum
News
Tech Support
Active Topics
Memberlist
Search
Help
Register
Login
Tips and Tricks
Crystal Reports Forum
:
Crystal Reports 9 through 2022
:
Tips and Tricks
Topic: Dates Year Error
Author
Message
NewJack
Newbie
Joined: 24 Nov 2009
Location: United States
Online Status: Offline
Posts: 6
Topic: Dates Year Error
Posted: 03 Dec 2009 at 6:56am
I am trying to create the following formula:
datediff ("ww", cdate(invoice_date), currentdate)
When I add it to my report I get an error:
"Dates must be between year 1 and year 9999."
In the DB2 DB it has the invoice field as a int. (20090123).
How can I work around this to get the number of days between these to dates? Do I have to convert the invoice date in Crystal? If so how?
Apprciate the help.
IP Logged
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Posted: 03 Dec 2009 at 7:08am
There are a number of ways to convert the int to a date field, here is one way:
datediff('ww',date(tonumber(left(totext(
{invoice_date},0),4)),tonumber(mid(totext({invoice_date},0),5,2)),tonumber(right(totext({invoice_date},0),2
))),currentdate)
IP Logged
NewJack
Newbie
Joined: 24 Nov 2009
Location: United States
Online Status: Offline
Posts: 6
Posted: 03 Dec 2009 at 7:33am
Thanks for the help....
I still get the error, but after playing around with what you send I did the following input and and output:
input: left(totext(invoice date),10)
output: 20,090,922
How do I remove the commas?
IP Logged
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Posted: 03 Dec 2009 at 7:51am
left(totext(invoice date),10
,''
)
IP Logged
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Posted: 03 Dec 2009 at 7:59am
If it was choking on a comma try...
datediff('ww',date(tonumber(left(totext(
{invoice_date},0,''),4)),tonumber(mid(totext({invoice_date},0,''),5,2)),tonumber(right(totext({invoice_date},0,''),2
))),currentdate)
Edited by DBlank - 03 Dec 2009 at 7:59am
IP Logged
NewJack
Newbie
Joined: 24 Nov 2009
Location: United States
Online Status: Offline
Posts: 6
Posted: 03 Dec 2009 at 8:07am
You Rock.
Thanks for your help.
IP Logged
Printable version
Forum Jump
-- Select Forum --
Announcements
Talk with the Author
Self-Publishing
Job Postings
New feature request
Report Design
Data Connectivity
Technical Questions
Tips and Tricks
Crystal Xcelsius
Report Design
Data Connectivity
Writing Code
Tips and Tricks
Report Design
Data Connectivity
Writing Code
Tips and Tricks
You
cannot
post new topics in this forum
You
cannot
reply to topics in this forum
You
cannot
delete your posts in this forum
You
cannot
edit your posts in this forum
You
cannot
create polls in this forum
You
cannot
vote in polls in this forum
HOME
|
FREE EBOOK
|
PROGRAMMING GUIDE
|
PURCHASE
|
REVIEWS
|
CONTACT ME
|
FAQ
|
LINKS
|
PRIVACY
|
CLICK PLAYS
|
BAEZL
© 2004-2026 Brian Bischof. All Rights Reserved.