Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Month/Year Selected - Convert Dates? Post Reply Post New Topic
Author Message
CRaid
Newbie
Newbie


Joined: 07 Jan 2013
Online Status: Offline
Posts: 13
Quote CRaid Replybullet Topic: Month/Year Selected - Convert Dates?
    Posted: 08 Jan 2013 at 12:10pm
I am not very familiar with various date functions.  It seems as though Crystal Reports only has functions which work based on the Current Date, right?  Well, how do you the following?
 
  User selects a month (any) and year (any), which is coming in via XML and they are both strings.  I need to convert them to the following for record selection against a date field in the table:
 
  - Month totals - this is a given since I would only need to to match up the month and year, right?
 
  - Quarterly totals - this one I don't really know how to do - please advise
 
  - YTD totals - I need some help with this also.
 
The year can be 2013, 2012, or whatever.  How do I write the record selections for these?  My first record selection is to be in the main report for YTD totals.  In the following footers, i then proceed to the Monthly totals, then the Quarterly totals.
 
I have tried using Date({ReportParameter.Option01}) to convert as such:
DateVar DateFrom := Date({ReportParameter.Option01})
//  Option01 is a string date
 
When I use it in the records selection, no records are pulled:
// Year To Date Selection:
{BAQReportResult.QuoteHed.EntryDate} >= {@DateFrom}
AND
{BAQReportResult.QuoteHed.EntryDate} <= {@DateTo}
 
Now, BAQReportResult.QuoteHed.EntryDate is a date field.
 
It has been quite awhile since I have had to use the record selection, so I may have forgotten something.
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 09 Jan 2013 at 12:01am
Hi..

The post is little confusing.. 

* You said Month and Year will be coming from XML
* You are converting {ReportParameter.Option01} to dateFrom, how you are arrving {reportparameter.option01} ? or is it a table field ?

Again you are comparing table date field with From and To dates.

Actually, you first you need to arrive fromdate and todate based on XML month and Year.


Example for DateFrom  (Month Totals)

date (Tonumber({XML Year}),Tonumber({XML Month}),01)

Example for DateTo  (Month Totals)

dateadd("m",+1,date (Tonumber({XML Year}),Tonumber({XML Month}),01))-1

Now you can compare your table date field with the above

{BAQReportResult.QuoteHed.EntryDate} in [date (Tonumber({XML Year}),Tonumber({XML Month}),01) to dateadd("m",+1,date (Tonumber({XML Year}),Tonumber({XML Month}),01))-1]




Thanks,
Sastry
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.