Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: CDate Problem!!! Post Reply Post New Topic
Author Message
santy2906
Newbie
Newbie


Joined: 19 Jan 2009
Location: United States
Online Status: Offline
Posts: 4
Quote santy2906 Replybullet Topic: CDate Problem!!!
    Posted: 19 Jan 2009 at 9:42am

Hi All,

Need your help in solving this strange problem of crystal report's date conversion.
 
Environment: C# .NET 2003, Crystal XI and SQL Server 2005.
 
Report is generated programmatically using a blog stored in the database.
We set RecordSelectionFormula that is a member of CRAXDRT.Report class. The string we set is - IN [CDate(15/01/2008) To CDate(28/01/2008)] and later call it's Export function to generate the report but this function fails and throws an error - Month should be between 1 and 12. Everything in our system is set to dd/MM/yyyy format even the SQL Server.
 
Am I missing something here i.e. we need to set the date time format while generating the report programmatically in .NET? if yes, what's the code to do that?? or there is a bug Im not aware of in Crystal XI?
 
Really need some1 to help me out here, it's pretty urgent!!!
 
Thanks in advance,
Santy
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Jan 2009 at 10:45am
Try
IN [CDate(15/01/2008,"dd/MM/yyyy") To CDate(28/01/2008,"dd/MM/yyyy")]
IP IP Logged
santy2906
Newbie
Newbie


Joined: 19 Jan 2009
Location: United States
Online Status: Offline
Posts: 4
Quote santy2906 Replybullet Posted: 19 Jan 2009 at 12:28pm
Hi DBlank,
 
I have done exactly the same way (as you mentioned) with double quotes. It's just that I forgot to add them here in the text.
 
Oops!!! I didn't see your post properly.... CDate don't take string format as the second parameter if I am not wrong but still I will try...
 
I mostly feel it's a crystal report problem as it is by default taking MM/dd/yyyy format or may be I am missing something - any property setting (to Report object) to take window's date format.
 
Thanks anyways for your time.
 
Santy


Edited by santy2906 - 19 Jan 2009 at 12:31pm
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Jan 2009 at 1:19pm
I can't access my crystal today but I beleive youy can set your date type defaults in Report Setup. Did you check there?
IP IP Logged
Savan
Senior Member
Senior Member
Avatar

Joined: 14 Dec 2007
Location: India
Online Status: Offline
Posts: 162
Quote Savan Replybullet Posted: 19 Jan 2009 at 11:11pm
i think this also can be used
IN [date(2008,01,15) To Date(2008,01,28)]
Thanks
Savan
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Jan 2009 at 7:25am
Hi Santy,
Sorry about the incorrect info before. Vacation has a way of turning the brain off temporarily Ermm
I looked and did not see any general setting for putting a date into earopean format without using month names.
You can go into custom settings and try to set it there but in testing I did not have any luck with that altering my field displays and I am not sure if that will address it at the join level.
IN [Date(#15/01/2008#) To Date(#28/01/2008#)] should work but it displays back as M/d/yyyy so I am not sure how that will mess up the rest of your report.
Sorry I could not be of more help...seems like there should be a general setting to address such a standard format...
IP IP Logged
santy2906
Newbie
Newbie


Joined: 19 Jan 2009
Location: United States
Online Status: Offline
Posts: 4
Quote santy2906 Replybullet Posted: 21 Jan 2009 at 2:44pm
Savan,
 
Thanks 4 replying but I tried that also but it's throwing the same error message.
 
Santy
IP IP Logged
santy2906
Newbie
Newbie


Joined: 19 Jan 2009
Location: United States
Online Status: Offline
Posts: 4
Quote santy2906 Replybullet Posted: 21 Jan 2009 at 2:49pm
Hi DBlank,
 
Actually, if you enclose date string in #s for CDate, by default it uses MM/dd/yyyy format but I need dd/MM/yyyy format so your solution IN [Date(#15/01/2008#) To Date(#28/01/2008#)]  won't work here bcoz it will intepret 15 as the month.
 
Source: Crystal Reports for CDate
 
Thanks,
Santy


Edited by santy2906 - 21 Jan 2009 at 2:50pm
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 21 Jan 2009 at 7:18pm
Hmmmm,
I added the Date(#15/01/2008#) in a formula and it acccepted fine but displays it as "1/15/2008" when i put the formula in the report.
Just as a test did you try and swap the
IN [CDate(15/01/2008) To CDate(28/01/2008)]
to
IN [CDate(01/15/2008) To CDate(01/28/2008)]
to validate this is exactly what it is choking on and not another date field somwhere else?
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
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



This page was generated in 0.016 seconds.