Skip to Content

Weekly Report query help in crystal report

Hi Experts,

This report shows the sales order doctotal country wise

I need this weekly report column. The below query shows the month and year i need weekly report. Here with i have attached the sample output screen shot for reference.

DECLARE @CurrentYear as Integer;

DECLARE @CurrentMonth as Integer;

DECLARE @HistoricYears as Integer;

DECLARE @CURRENTWEEK AS INTEGER;

SET @CurrentYear = DATEPART(YEAR,GETDATE());

SET @CurrentMonth = DATEPART(MONTH,GETDATE());

SELECT ORDR.CardCode,ORDR.CardName,ORDR.CardCode,(ORDR.DocTotal - ORDR.VatSum) As DocTotal,ORDR.DocDate,ORDR.SlpCode

,OCRD.Country

,OCRY.Name

,DATEPART("Month",DocDate) As 'Month'

,DATEPART("Year",DocDate) As 'Year'

,DATEPART("WEEK",DOCDATE) AS 'WEEK'

FROM ORDR

INNER JOIN OCRD ON

ORDR.CardCode = OCRD.CardCode

INNER JOIN OCRY ON

OCRD.Country = OCRY.Code

WHERE ORDR.CANCELED = 'N'

AND (CAST(ORDR.DocDate AS DATE) BETWEEN CAST(CAST((@CurrentYear - 1)AS Varchar) + '-01-01' AS DATE)

AND DATEADD(YEAR,-1,GETDATE())

OR

CAST(ORDR.DocDate AS DATE) BETWEEN CAST(CAST((@CurrentYear)AS Varchar) + '-01-01' AS DATE)

AND CAST(GETDATE()AS DATE))

Formula in crystal report:

Today:

-----

IF {Command.DocDate} = CurrentDate THEN

{Command.DocTotal}

ELSE 0

month

-----

IF DatePart("m",{Command.DocDate}) = Datepart("m",CurrentDate)

AND Datepart("YYYY",{Command.DocDate}) = Datepart("YYYY",CurrentDate) THEN

{Command.DocTotal}

ELSE 0

Current Year:

------------

IF Datepart("YYYY",{Command.DocDate}) = Datepart("YYYY",Currentdate) THEN

{Command.DocTotal}

ELSE 0

This week: I need this report formula

??????

Thanks & Regards

Vinoth

Capture.PNG (45.9 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Dec 17, 2015 at 12:42 PM

    if(

    {Command.DocDate} >= dateadd('d',-weekday(currentdate,crmonday),currentdate)

    and

    {Command.DocDate} <= dateadd('d',7,dateadd('d',-weekday(currentdate,crmonday),currentdate)))

    then

    {Command.DocTotal}

    else

    0

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.