Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 24th, 2005, 09:07 AM
Registered User
 
Join Date: Aug 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default help with date formula

Hello.

Please help. Assistance is needed and appreciated.

I have a date formula which displays a date string from a table column called ContractDate in this format 010305 - which is March 2005 for example. My formula is as follows:

@contract
Local StringVar message := "";
If {ContractDate} = "000000" Then
         (
          message := "Returning to Contract";
          )
else CStr(CDateTime({ContractDate), "MM""/""yyyy")

If the ContractDate has a "0000" value, a message is displayed "Returning to Contract". Thats fine.

My problem is that if the date is not a correct date e.g. I have a value 011612, Crystal reports outputs the date as 12/-4714, which is totally wrong. So what do I do to check whether the date is a valid date or not. Is there a conditional formula i could write to check this and then if an invalid date shows up i could write an appropriate message, otherwise display the date?

Please help. I am using CR10. Thanks.
 
Old September 7th, 2005, 11:22 AM
Authorized User
 
Join Date: Dec 2004
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i am not sure what u exactly want. I am giving you the formula according to my understanding of what u wrote. Sorry if i confused u.here i am assuming that {ContractDate} is a string.

Local StringVar message := "";
If {ContractDate} = '000000' Then
         (
          message := "Returning to Contract";
          )
else if tonumber(mid({ContractDate},3,2)) > 12 then
'Date is not in correct format'
else
cstr(mid({ContractDate},3,2) & '/' & right({ContractDate},2))
 
Old September 12th, 2005, 07:07 AM
Registered User
 
Join Date: Aug 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your reply. The formula works. Thats is exactly what I needed. Cheers.






Similar Threads
Thread Thread Starter Forum Replies Last Post
formula sinha Crystal Reports 1 October 26th, 2005 12:53 PM
Help with a formula Corey Access 2 October 20th, 2005 10:48 AM
creating formula for date ct Excel VBA 1 October 6th, 2005 05:16 AM
Formula to convert date format narooma.12 Crystal Reports 0 April 20th, 2005 04:54 PM
Record selectionf formula for date Bhavin Crystal Reports 0 December 9th, 2004 11:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.