DATEDIFF - AGE
Just having some issues with doing a DATEDIFF with the Current Date and the student DATE OF BIRTH to acheive the AGE of the student
I want to show the students AGE in YYMM. The format of the DOB column is YYYYMMDD.
below are some example of the desired results
DOB
GETDATE()
Years
Months
YYMM
19790111
20140527
35
4
3505
19790219
20140527
35
3
3503
Similar Messages
-
Count Age - Datediff (not rounding up age)
How would you write the formula to calculate the age so that it doesn't round up?
DateDiff ("yyyy",{member_current_demographics.member_birthdate},{history_member_svc.date_of_service})
Ex:
Date of birth Date of Service Age
07/5/91 7/4/09 ???
My age calculation should be 17, and it isn't. It' s coming up at 18.
How can I write the formula different?
Please help!!
Edited by: TrangN on Aug 21, 2009 8:28 PMif cstr({member_current_demographics.member_birthdate}, "MMdd") > cstr(history_member_svc.date_of_service, "MMdd") then
formula = datepart("yyyy", history_member_svc.date_of_service) _
- datepart("yyyy", {member_current_demographics.member_birthdate}) - 1
else
formula = datepart("yyyy", history_member_svc.date_of_service) _
- datepart("yyyy", {member_current_demographics.member_birthdate})
end if
HTH,
Carl -
This report has been extended from an existing query that has been posted on this forum.
This report is an aging report for ALL trasnactions, both open and closed.
Is it possible to modify this query to report on OPEN / unreconciled trasnactions only?
select T0.shortname,T2.cardcode 'Customer Code',T2.cardname 'Name',T2.U_BU, T2.U_DEPT, sysdeb 'Debit Amount',syscred 'Credit Amount',
case T0.transtype
when '13' then 'INV'
when '14' then 'AR CN'
when '24' then 'INCOMING'
else 'Other'
end 'Type',
T1.BaseRef'Trans #',
case T0.transtype
when '13' then
(Select Comments from OINV where OINV.Transid=T1.Transid)
else '-'
end 'Inv.Rem.',
(Select SeriesName From NNM1 Where Series=T1.DocSeries and ObjectCode=T0.TransType)'Series',
T0.Ref1,
fccurrency 'BP Currency',
CONVERT(VARCHAR(10), T0.refdate, 103)'Posting Date' ,
CONVERT(VARCHAR(10), T0.duedate, 103) 'Due Date',
CONVERT(VARCHAR(10), T0.taxdate, 103) 'Doc Date' ,
CASE
when (DATEDIFF(dd,T0.refdate,current_timestamp))+1 < 31
then
case
when syscred <> 0 then syscred * - 1
else sysdeb
end
end "0-30 days",
case when ((datediff(dd,T0.refdate,current_timestamp))+1 > 30
and (datediff(dd,T0.refdate,current_timestamp))+1< 61)
then
case
when syscred <> 0 then syscred * - 1
else sysdeb
end
end "31 to 60 days",
case when ((datediff(dd,T0.refdate,current_timestamp))+1 > 60
and (datediff(dd,T0.refdate,current_timestamp))+1< 91)
then
case
when syscred <> 0 then syscred * - 1
else sysdeb
end
end "61 to 90 days",
CASE
when (DATEDIFF(dd,T0.refdate,current_timestamp))+1 > 90
then
case
when syscred= 0 then sysdeb
when sysdeb= 0 then syscred * - 1
end
end "90 + days"
from JDT1 T0
Inner Join OJDT T1 On T1.TransId=T0.TransId
left outer join
OCRD T2 ON T2.cardcode =T0.shortname where
T2.cardtype = 'c' and T0.intrnmatch = '0' and
T2.U_Bu = %0and T2.U_Dept = %1
ORDER BY T2.CARDCODE, T0.taxdate
Thanks in advanced LisaThanks for the feedback Jule - I have changed the query as is as below
Unfortunately, the query is still reporting ALL transactions not just unreconciled transations.
Would be grateful for any assistance.
Cheers Lisa
select T0.shortname,T2.cardcode 'Customer Code',T2.cardname 'Name',T2.U_BU, T2.U_DEPT, balscdeb 'Debit Amount',balsccred 'Credit Amount',
case T0.transtype
when '13' then 'INV'
when '14' then 'AR CN'
when '24' then 'INCOMING'
else 'Other'
end 'Type',
T1.BaseRef'Trans #',
case T0.transtype
when '13' then
(Select Comments from OINV where OINV.Transid=T1.Transid)
else '-'
end 'Inv.Rem.',
(Select SeriesName From NNM1 Where Series=T1.DocSeries and ObjectCode=T0.TransType)'Series',
T0.Ref1,
fccurrency 'BP Currency',
CONVERT(VARCHAR(10), T0.refdate, 103)'Posting Date' ,
CONVERT(VARCHAR(10), T0.duedate, 103) 'Due Date',
CONVERT(VARCHAR(10), T0.taxdate, 103) 'Doc Date' ,
CASE
when (DATEDIFF(dd,T0.refdate,current_timestamp))+1 < 31
then
case
when balsccred <> 0 then balsccred * - 1
else balscdeb
end
end "0-30 days",
case when ((datediff(dd,T0.refdate,current_timestamp))+1 > 30
and (datediff(dd,T0.refdate,current_timestamp))+1< 61)
then
case
when balsccred <> 0 then balsccred * - 1
else balscdeb
end
end "31 to 60 days",
case when ((datediff(dd,T0.refdate,current_timestamp))+1 > 60
and (datediff(dd,T0.refdate,current_timestamp))+1< 91)
then
case
when balsccred <> 0 then balsccred * - 1
else balscdeb
end
end "61 to 90 days",
CASE
when (DATEDIFF(dd,T0.refdate,current_timestamp))+1 > 90
then
case
when balsccred= 0 then balscdeb
when balscdeb= 0 then balsccred * - 1
end
end "90 + days"
from JDT1 T0
Inner Join OJDT T1 On T1.TransId=T0.TransId
left outer join
OCRD T2 ON T2.cardcode =T0.shortname where
T2.cardtype = 'c' and
T2.U_Bu = [%0]and T2.U_Dept = [%1]
ORDER BY T2.CARDCODE, T0.taxdate -
Dear Experts
can anybody please help me in getting ageing report project wise . We already have the ageing report Debtors or Creditors wise
in the system but i want the ageing report project wise
warm regards
anandHi Rajshree
Try this One for customers, hopefully you should then be able to amend it to the Supplier Version
select T0.shortname,T2.cardcode 'Customer Code',T2.cardname 'Name', sysdeb 'Debit Amount',syscred 'Credit Amount',
case T0.transtype
when '13' then 'INV'
when '14' then 'AR CN'
when '24' then 'INCOMING'
else 'Other'
end 'Type',
T1.BaseRef'Trans #',
case T0.transtype
when '13' then
(Select Comments from OINV where OINV.Transid=T1.Transid)
else '-'
end 'Inv.Rem.',
(Select SeriesName From NNM1 Where Series=T1.DocSeries and ObjectCode=T0.TransType)'Series',
T0.Ref1,
fccurrency 'BP Currency',
CONVERT(VARCHAR(10), T0.refdate, 103)'Posting Date' ,
CONVERT(VARCHAR(10), T0.duedate, 103) 'Due Date',
CONVERT(VARCHAR(10), T0.taxdate, 103) 'Doc Date' ,
CASE
when (DATEDIFF(dd,T0.refdate,current_timestamp))+1 < 31
then
case
when syscred <> 0 then syscred * - 1
else sysdeb
end
end "0-30 days",
case when ((datediff(dd,T0.refdate,current_timestamp))+1 > 30
and (datediff(dd,T0.refdate,current_timestamp))+1< 61)
then
case
when syscred <> 0 then syscred * - 1
else sysdeb
end
end "31 to 60 days",
case when ((datediff(dd,T0.refdate,current_timestamp))+1 > 60
and (datediff(dd,T0.refdate,current_timestamp))+1< 91)
then
case
when syscred <> 0 then syscred * - 1
else sysdeb
end
end "60 to 90 days",
case when ((datediff(dd,T0.refdate,current_timestamp))+1 > 90
and (datediff(dd,T0.refdate,current_timestamp))+1< 121)
then
case
when syscred <> 0 then syscred * - 1
else sysdeb
end
end "91 to 120 days",
case when ((datediff(dd,T0.refdate,current_timestamp))+1 > 120
and (datediff(dd,T0.refdate,current_timestamp))+1< 151)
then
case
when syscred <> 0 then syscred * - 1
else sysdeb
end
end "121 to 150 days",
case when ((datediff(dd,T0.refdate,current_timestamp))+1 > 150
and (datediff(dd,T0.refdate,current_timestamp))+1< 181)
then
case
when syscred <> 0 then syscred * - 1
else sysdeb
end
end "151 to 180 days",
case when ((datediff(dd,T0.refdate,current_timestamp))+1 > 180
and (datediff(dd,T0.refdate,current_timestamp))+1< 221)
then
case
when syscred <> 0 then syscred * - 1
else sysdeb
end
end "181 to 220 days",
CASE
when (DATEDIFF(dd,T0.refdate,current_timestamp))+1 > 220
then
case
when syscred= 0 then sysdeb
when sysdeb= 0 then syscred * - 1
end
end "220 + days"
from JDT1 T0
Inner Join OJDT T1 On T1.TransId=T0.TransId
left outer join
OCRD T2 ON T2.cardcode =T0.shortname where
T2.cardtype = 'c' and T0.intrnmatch = '0'
and (T0.BalDueCred + T0.BalDueDeb) > 0
ORDER BY T2.CARDCODE, T0.taxdate
Kind regards
Sean -
Can I report on the AGE of open Work Items? How? Group into Buckets?
Is there a way to report on the age of open work items?
Perhaps a bar graph that has several buckets.
a. Over 364
b. 180 to 364
c. 90 to 179
d. 1 to 89
And then a COUNT in each bucket.
For example, if a Work Item is open longer than 364 day, it would appear in bucket "a" as a count of 1. Say there are a total of 45 Work Items that were opened older than 364 days, then "45" would appear in column "a" now say that there are 100 work items open that are 1 to 89 days old, then 100 would appear in the "d" bucket.
Make sense? How can I report like this?Hi mrpeepers,
You can use following MDX script when you create this report that uses TfsOlapReportDS
with
member [Measures].[Age]
As
IIF([Measures].[Current Work Item Count]>0,DateDiff("d",cdate([System_CreatedDate].[Date].CurrentMember .name),Now()),null)
member [Measures].[AgeRange]
as
case
when [Measures].[Age] >70 then 70
when [Measures].[Age] >60 then 60
when [Measures].[Age] >50 then 50
when [Measures].[Age] >40 then 40
when [Measures].[Age] >30 then 30
when [Measures].[Age] >20 then 20
when [Measures].[Age] >10 then 10
when [Measures].[Age] >0 then 0
when [Measures].[Age] <0 then -1
else null
end
SELECT
non empty
{[Measures].[Current Work Item Count],[Measures].[Age] ,[Measures].[AgeRange]}
ON COLUMNS,
[System_CreatedDate].[Date].[Date].AllMembers on Rows
FROM [Current Work Item]
And then, drop a Chart to report designer, select “Current_Work_Item_Count” as datafield, AgeRange as category field.
Best Regards,
Ruiz
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Sincerely,
Ruiz Yi -
Dear all,
We are on SAP B1 2007 PL42 and using Moving average as our cost valuation method.
It doesn't have an inbuilt stock aging report, I have searched through the forum but none of the queries arebshowing the correct aging of stocks. Could anyone have a query/report/addon for stock aging?
Kind Regards,
AsifHi,
Try this one,with warehouse code as input parameter
select b.code, b.name, b.Wh, b.Bal, b.Val,
isnull(case when b.days <30 then b.bal end,0)'0-30 Days' ,
isnull(case when b.days between 30 and 60 then b.bal end,0) '30-60 Days',
isnull(case when b.days between 60 and 90 then b.bal end,0) '60-90 Days',
isnull(case when b.days between 90 and 120 then b.bal end,0) '90-120 Days',
isnull(case when b.days between 120 and 150 then b.bal end,0) '120-150 Days',
isnull(case when b.days between 150 and 180 then b.bal end,0) '150-180 Days',
isnull(case when b.days >180 then b.bal end,0) 'Above 180 Days'
from (
select a.code,a.name,a.wh,a.bal,a.val,datediff(dd,dt,getdate())'days'
from (
select max(t0.itemcode)'Code',max(t0.Dscription)'Name',
max(t0.Warehouse)'Wh',
sum(t0.inqty-t0.outqty)'Bal',sum(t0.transvalue)'Val',max(t0.docdate)'dt'
from oinm t0 inner join oitm t1 on t0.itemcode=t1.itemcode
where t0.warehouse='[%1]'
group by t0.itemcode
)a
)b order by code -
How to prepare Aging report in another system
Hi,
I have seen aging report for customer in SAP B1, its okay but not serve my purpose. i want this report little difference.
i sent a link file for aging report like this way.
[Aging Report |
http://www.sendspace.com/file/v8jbt3]
if it is possible to make this report please help me about this.
Regards,
Mizan
Edited by: mizan700 on Dec 29, 2010 11:39 AMHi Mizan,
Try this as a command in Crystal Report:
SELECT T0.CardName,T0.DocNum,T0.DocDueDate, DateDiff(DD,T0.DocDueDate,getDate()) as Overdue, T0.DocTotal-T0.PaidToDate as 'Due Amount'
FROM dbo.OINV T0
where T0.DocStatus='O' AND DateDiff(DD,T0.DocDueDate,getDate())>0
UNION ALL
SELECT T0.CardName,Null,NULL, NULL, SUM(T0.DocTotal-T0.PaidToDate) as 'Due Amount'
FROM dbo.OINV T0
where T0.DocStatus='O' AND DateDiff(DD,T0.DocDueDate,getDate())>0
GROUP BY T0.CardName
Order By T0.CardName,T0.DocDueDate DESC
Rank can be by CR function.
Thanks,
Gordon -
Open invoice customer ageing query
I have set up a query to find a customer aging report - open ivoices. I just want to have open records... does anyone have a better query for this?
SELECT TOP (100) PERCENT dbo.OCRD.CardName, dbo.OCRD.Balance, (CASE WHEN DATEDIFF(DD, T0.REFDATE, GETDATE()) BETWEEN 0 AND
30 THEN CASE WHEN T1.SYSCred <> 0 THEN T1.SYSCred * - 1 ELSE T1.SYSDeb END ELSE 0 END) AS [0-30], (CASE WHEN DATEDIFF(DD, T0.REFDATE, GETDATE())
BETWEEN 31 AND 60 THEN CASE WHEN T1.SYSCred <> 0 THEN T1.SYSCred * - 1 ELSE T1.SYSDeb END ELSE 0 END) AS [31-60], (CASE WHEN DATEDIFF(DD,
T0.REFDATE, GETDATE()) BETWEEN 61 AND 90 THEN CASE WHEN T1.SYSCred <> 0 THEN T1.SYSCred * - 1 ELSE T1.SYSDeb END ELSE 0 END) AS [61-90],
(CASE WHEN DATEDIFF(DD, T0.REFDATE, GETDATE()) > 91 THEN CASE WHEN T1.SYSCred <> 0 THEN T1.SYSCred * - 1 ELSE T1.SYSDeb END ELSE 0 END) AS [90+],
dbo.OCRD.CardType, T1.TransType, T1.TransCode, T1.LineMemo, T1.BaseRef, dbo.OCRD.CardCode, T1.BalDueDeb
FROM dbo.OJDT AS T0 INNER JOIN
dbo.JDT1 AS T1 ON T1.TransId = T0.TransId INNER JOIN
dbo.OCRD ON dbo.OCRD.CardCode = T1.ShortName
WHERE (dbo.OCRD.Balance >= 1) AND (dbo.OCRD.CardType = 'C') AND (T1.BalDueDeb > 0)
ORDER BY dbo.OCRD.CardName
Regards,
knutKnut,
Try this:
SELECT T2.CardName, T2.Balance,
(CASE WHEN DATEDIFF(DD, T0.REFDATE, GETDATE()) BETWEEN 0 AND
30 THEN CASE WHEN T1.SYSCred != 0 THEN -T1.SYSCred ELSE T1.SYSDeb END ELSE 0 END) AS '0-30',
(CASE WHEN DATEDIFF(DD, T0.REFDATE, GETDATE()) BETWEEN 31 AND
60 THEN CASE WHEN T1.SYSCred != 0 THEN -T1.SYSCred ELSE T1.SYSDeb END ELSE 0 END) AS '31-60',
(CASE WHEN DATEDIFF(DD, T0.REFDATE, GETDATE()) BETWEEN 61 AND
90 THEN CASE WHEN T1.SYSCred != 0 THEN -T1.SYSCred ELSE T1.SYSDeb END ELSE 0 END) AS '61-90',
(CASE WHEN DATEDIFF(DD, T0.REFDATE, GETDATE()) >90
THEN CASE WHEN T1.SYSCred != 0 THEN -T1.SYSCred ELSE T1.SYSDeb END ELSE 0 END) AS '90+',
T1.TransType, T1.TransCode, T1.LineMemo, T1.BaseRef, T2.CardCode
FROM dbo.OJDT T0
INNER JOIN dbo.JDT1 T1 ON T1.TransId = T0.TransId
INNER JOIN dbo.OCRD T2 ON T2.CardCode = T1.ShortName
WHERE (T2.Balance >= 1) AND (T2.CardType = 'C') AND (T1.BalDueDeb != T1.BalDueCred)
Thanks,
Gordon -
Aging report from a different base date
Hi,
There is a requirement in Aging report. The report should show the the 30, 30-60, 60-90 etc with a different base date/(reference date (OPEN DATE) in stead of the current date. In this case current date should be shown as RUNDATE and there should be one more date field as OPEN DATE in the page footer.
Please help me to solve this. Thanks in advance.
BABASHARIAdd a parameter for the date that you want to age by. Use the datediff() function to determine the age of each item in a formula field that uses that age to group items by the range of dates desired (basic syntax):
dim days as number
days = datediff("d",{due date}, {?date parameter})
if days < 31
formula = " 0 to 30"
elseif days < 61
formula = " 31 to 60"
elseif days < 91
formula = " 61 to 90"
elseif days < 121
formula = " 91 to 120"
else
formula = "Over 120"
end if
HTH,
Carl -
Dear Guys,
I have tried for aging report query , but still my expected results is not come. Please go through below the table and script data for your reference. Please wirte a query for aging report.
USE [SAMPLES]
GO
/****** Object: Table [dbo].[NEW_DCB_REPORT] Script Date: 02/12/2015 01:19:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[NEW_DCB_REPORT](
[MFDB_LedgerNumber] [int] IDENTITY(1,1) NOT NULL,
[MFDB_TxnDate] [datetime] NOT NULL,
[MFDB_StateId] [int] NOT NULL,
[MFDB_RegionId] [int] NOT NULL,
[MFDB_BranchId] [int] NOT NULL,
[MFDB_SHGId] [int] NOT NULL,
[MFDB_SHGName] [varchar](75) NOT NULL,
[MFDB_ShgMemberId] [int] NOT NULL,
[MFDB_MemberName] [varchar](50) NOT NULL,
[MFDB_VillageId] [int] NOT NULL,
[MFDB_LoanNumber] [int] NOT NULL,
[MFDB_LoanAmount] [int] NOT NULL,
[MFDB_DisbursedDate] [datetime] NOT NULL,
[MFDB_DemandDate] [datetime] NULL,
[MFDB_CollectionDate] [datetime] NULL,
[MFDB_InstallmentNumber] [int] NOT NULL,
[MFDB_ArrearPrincipal] [numeric](18, 2) NOT NULL,
[MFDB_ArrearInterest] [numeric](18, 2) NOT NULL,
[MFDB_DemandPrincipal] [numeric](18, 2) NOT NULL,
[MFDB_DemandInterest] [numeric](18, 2) NOT NULL,
[MFDB_TotDemandPrincipal] [numeric](18, 2) NOT NULL,
[MFDB_TotDemandInterest] [numeric](18, 2) NOT NULL,
[MFDB_AdvOBPrincipal] [numeric](18, 2) NOT NULL,
[MFDB_AdvOBInterest] [numeric](18, 2) NOT NULL,
[MFDB_CollectedPrincipal] [numeric](18, 2) NOT NULL,
[MFDB_CollectedInterest] [numeric](18, 2) NOT NULL,
[MFDB_AdvCBPrincipal] [numeric](18, 2) NOT NULL,
[MFDB_AdvCBInterest] [numeric](18, 2) NOT NULL,
[MFDB_BalancePrincipal] [numeric](18, 2) NOT NULL,
[MFDB_BalanceInterest] [numeric](18, 2) NOT NULL,
[MFDB_OS_Pri] [numeric](18, 2) NOT NULL,
[MFDB_OS_Int] [numeric](18, 2) NOT NULL,
[MFDB_RepaymentPercentage] [int] NOT NULL,
[MFDB_LoanSchemeId] [int] NOT NULL,
[MFDB_LActivityId] [int] NOT NULL,
[MFDB_LActSpecId] [int] NOT NULL,
[MFDB_FundAgencyId] [int] NOT NULL,
[MFDB_LSourceId] [int] NOT NULL,
[MFDB_Months] [varchar](15) NOT NULL,
[MFDB_PanchayatId] [int] NOT NULL,
[MFDB_PanchayatName] [varchar](100) NOT NULL,
[MFDB_VillageName] [varchar](100) NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
USE [SAMPLES];
SET NOCOUNT ON;
SET XACT_ABORT ON;
GO
SET IDENTITY_INSERT [dbo].[NEW_DCB_REPORT] ON;
BEGIN TRANSACTION;
INSERT INTO [dbo].[NEW_DCB_REPORT]([MFDB_LedgerNumber], [MFDB_TxnDate], [MFDB_StateId], [MFDB_RegionId], [MFDB_BranchId], [MFDB_SHGId], [MFDB_SHGName], [MFDB_ShgMemberId], [MFDB_MemberName], [MFDB_VillageId], [MFDB_LoanNumber], [MFDB_LoanAmount], [MFDB_DisbursedDate], [MFDB_DemandDate], [MFDB_CollectionDate], [MFDB_InstallmentNumber], [MFDB_ArrearPrincipal], [MFDB_ArrearInterest], [MFDB_DemandPrincipal], [MFDB_DemandInterest], [MFDB_TotDemandPrincipal], [MFDB_TotDemandInterest], [MFDB_AdvOBPrincipal], [MFDB_AdvOBInterest], [MFDB_CollectedPrincipal], [MFDB_CollectedInterest], [MFDB_AdvCBPrincipal], [MFDB_AdvCBInterest], [MFDB_BalancePrincipal], [MFDB_BalanceInterest], [MFDB_OS_Pri], [MFDB_OS_Int], [MFDB_RepaymentPercentage], [MFDB_LoanSchemeId], [MFDB_LActivityId], [MFDB_LActSpecId], [MFDB_FundAgencyId], [MFDB_LSourceId], [MFDB_Months], [MFDB_PanchayatId], [MFDB_PanchayatName], [MFDB_VillageName])
SELECT 18, '20140422 00:00:00.000', 6, 16, 67, 5514, N'MAHALAXMI-5514', 66735, N'SUNITA', 4624, 1, 10000, '20140422 00:00:00.000', NULL, NULL, 0, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 10000.00, 1051.00, 0, 3, 4, 77, 3, 2, N'Apr - 14', 2927, N'PALI', N'PALI' UNION ALL
SELECT 162, '20140521 00:00:00.000', 6, 16, 67, 5514, N'MAHALAXMI-5514', 66735, N'SUNITA', 4624, 1, 10000, '20140422 00:00:00.000', '20140521 00:00:00.000', NULL, 1, 0.00, 0.00, 0.00, 150.00, 0.00, 150.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 150.00, 10000.00, 1051.00, 0, 3, 4, 77, 3, 2, N'May - 14', 2927, N'PALI', N'PALI' UNION ALL
SELECT 13932, '20140621 00:00:00.000', 6, 16, 67, 5514, N'MAHALAXMI-5514', 66735, N'SUNITA', 4624, 1, 10000, '20140422 00:00:00.000', '20140621 00:00:00.000', NULL, 2, 0.00, 150.00, 909.00, 150.00, 909.00, 300.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 909.00, 300.00, 10000.00, 1051.00, 0, 3, 4, 77, 3, 2, N'Jun - 14', 2927, N'PALI', N'PALI' UNION ALL
SELECT 32505, '20140721 00:00:00.000', 6, 16, 67, 5514, N'MAHALAXMI-5514', 66735, N'SUNITA', 4624, 1, 10000, '20140422 00:00:00.000', '20140721 00:00:00.000', NULL, 3, 909.00, 300.00, 909.00, 136.00, 1818.00, 436.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 1818.00, 436.00, 10000.00, 1051.00, 0, 3, 4, 77, 3, 2, N'Jul - 14', 2927, N'PALI', N'PALI' UNION ALL
SELECT 62524, '20140821 00:00:00.000', 6, 16, 67, 5514, N'MAHALAXMI-5514', 66735, N'SUNITA', 4624, 1, 10000, '20140422 00:00:00.000', '20140821 00:00:00.000', NULL, 4, 1818.00, 436.00, 909.00, 123.00, 2727.00, 559.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 2727.00, 559.00, 10000.00, 1051.00, 0, 3, 4, 77, 3, 2, N'Aug - 14', 2927, N'PALI', N'PALI' UNION ALL
SELECT 100871, '20140921 00:00:00.000', 6, 16, 67, 5514, N'MAHALAXMI-5514', 66735, N'SUNITA', 4624, 1, 10000, '20140422 00:00:00.000', '20140921 00:00:00.000', NULL, 5, 2727.00, 559.00, 909.00, 109.00, 3636.00, 668.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 3636.00, 668.00, 10000.00, 1051.00, 0, 3, 4, 77, 3, 2, N'Sep - 14', 2927, N'PALI', N'PALI' UNION ALL
SELECT 153679, '20141021 00:00:00.000', 6, 16, 67, 5514, N'MAHALAXMI-5514', 66735, N'SUNITA', 4624, 1, 10000, '20140422 00:00:00.000', '20141021 00:00:00.000', NULL, 6, 3636.00, 668.00, 909.00, 96.00, 4545.00, 764.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 4545.00, 764.00, 10000.00, 1051.00, 0, 3, 4, 77, 3, 2, N'Oct - 14', 2927, N'PALI', N'PALI' UNION ALL
SELECT 203840, '20141119 00:00:00.000', 6, 16, 67, 5514, N'MAHALAXMI-5514', 66735, N'SUNITA', 4624, 1, 10000, '20140422 00:00:00.000', NULL, '20141119 00:00:00.000', 2, 4545.00, 764.00, 0.00, 0.00, 4545.00, 764.00, 0.00, 0.00, 10000.00, 150.00, 5455.00, 0.00, 0.00, 614.00, 0.00, 901.00, 0, 3, 4, 77, 3, 2, N'Nov - 14', 2927, N'PALI', N'PALI' UNION ALL
SELECT 291259, '20141221 00:00:00.000', 6, 16, 67, 5514, N'MAHALAXMI-5514', 66735, N'SUNITA', 4624, 1, 10000, '20140422 00:00:00.000', '20141221 00:00:00.000', NULL, 8, 0.00, 614.00, 909.00, 68.00, 909.00, 682.00, 5455.00, 0.00, 0.00, 0.00, 4546.00, 0.00, 0.00, 682.00, 0.00, 901.00, 0, 3, 4, 77, 3, 2, N'Dec - 14', 2927, N'PALI', N'PALI' UNION ALL
SELECT 363176, '20150121 00:00:00.000', 6, 16, 67, 5514, N'MAHALAXMI-5514', 66735, N'SUNITA', 4624, 1, 10000, '20140422 00:00:00.000', '20150121 00:00:00.000', NULL, 9, 0.00, 682.00, 909.00, 55.00, 909.00, 737.00, 4546.00, 0.00, 0.00, 0.00, 3637.00, 0.00, 0.00, 737.00, 0.00, 901.00, 0, 3, 4, 77, 3, 2, N'Jan - 15', 2927, N'PALI', N'PALI'
COMMIT;
RAISERROR (N'[dbo].[NEW_DCB_REPORT]: Insert Batch: 1.....Done!', 10, 1) WITH NOWAIT;
GO
SET IDENTITY_INSERT [dbo].[NEW_DCB_REPORT] OFF;
I expected results as below:
Report As On Date: 30-10-2014
S.No. SHG NAME MEMBER NAME <=30 31-60 61-90 91-120 91-180 181-365 365 - 689 Above 2 Yrs
1 MAHALAXMI-5514 SUNITA 0 909 1818 2727 3636 4545 0 0
Report As On Date:
30-10-2014
S.No.
SHG NAME
MEMBER NAME
<=30
31-60
61-90
91-120
91-180
181-365
365 - 689
Above 2 Yrs
1
MAHALAXMI-5514
SUNITA
0
909
1818
2727
3636
4545
0
0Thanks for your replay, I have checked your query it seems nearly ok, Please find my script which i tried above for the same.
DECLARE @i_AsOnDate AS DATETIME = '2014-09-30'
;WITH CA1 AS
SELECT ROW_NUMBER() OVER(Order By DR.MFDB_SHGName,DR.MFDB_MemberName)
AS SerialNumber,
DR.MFDB_SHGId
AS ShgId,
DR.MFDB_SHGName
AS ShgName,
DR.MFDB_ShgMemberId
AS MemId,
DR.MFDB_MemberName
AS MemName,
ISNULL((SELECT CAST(SUM(LD.MFDB_StdPrincipal) AS BIGINT )
FROM MFDB_LOAN_DISBURSEMENT LD
WHERE LD.MFDB_SHGId
= DR.MFDB_SHGId
AND LD.MFDB_ShgMemberId
= DR.MFDB_ShgMemberId
AND LD.MFDB_LoanNumber
= DR.MFDB_LoanNumber
AND LD.MFDB_ApprovalStatus = 1
AND DATEDIFF(DAY,@i_AsOnDate,LD.MFDB_CollectionDate) > 0 ),0)
AS YETDUE,
ISNULL((SELECT TOP 1 CAST(ND.MFDB_BalancePrincipal AS BIGINT )
FROM dbo.MFDB_NEW_DCB_REPORT ND
WHERE ND.MFDB_SHGId
= DR.MFDB_SHGId
AND ND.MFDB_ShgMemberId
= DR.MFDB_ShgMemberId
AND ND.MFDB_LoanNumber
= DR.MFDB_LoanNumber
AND DATEDIFF(Day,ND.MFDB_TxnDate,@i_AsOnDate) >= 0
AND DATEDIFF(Day,ND.MFDB_TxnDate,@i_AsOnDate) <= 30
ORDER BY ND.MFDB_LedgerNumber DESC),0)
AS '0-30',
ISNULL((SELECT TOP 1 CAST(ND.MFDB_BalancePrincipal AS BIGINT )
FROM dbo.MFDB_NEW_DCB_REPORT ND
WHERE ND.MFDB_SHGId
= DR.MFDB_SHGId
AND ND.MFDB_ShgMemberId
= DR.MFDB_ShgMemberId
AND ND.MFDB_LoanNumber
= DR.MFDB_LoanNumber
AND DATEDIFF(Day,ND.MFDB_TxnDate,@i_AsOnDate) <= 60
AND DATEDIFF(Day,ND.MFDB_TxnDate,@i_AsOnDate) > 30
ORDER BY ND.MFDB_LedgerNumber DESC),0)
AS '31-60',
ISNULL((SELECT TOP 1 CAST(ND.MFDB_BalancePrincipal AS BIGINT )
FROM dbo.MFDB_NEW_DCB_REPORT ND
WHERE ND.MFDB_SHGId
= DR.MFDB_SHGId
AND ND.MFDB_ShgMemberId
= DR.MFDB_ShgMemberId
AND ND.MFDB_LoanNumber
= DR.MFDB_LoanNumber
AND DATEDIFF(Day,ND.MFDB_TxnDate,@i_AsOnDate) <= 90
AND DATEDIFF(Day,ND.MFDB_TxnDate,@i_AsOnDate) > 60
ORDER BY ND.MFDB_LedgerNumber DESC),0)
AS '61-90',
ISNULL((SELECT TOP 1 CAST(ND.MFDB_BalancePrincipal AS BIGINT )
FROM dbo.MFDB_NEW_DCB_REPORT ND
WHERE ND.MFDB_SHGId
= DR.MFDB_SHGId
AND ND.MFDB_ShgMemberId
= DR.MFDB_ShgMemberId
AND ND.MFDB_LoanNumber
= DR.MFDB_LoanNumber
AND DATEDIFF(Day,ND.MFDB_TxnDate,@i_AsOnDate) <= 120
AND DATEDIFF(Day,ND.MFDB_TxnDate,@i_AsOnDate) > 90
ORDER BY ND.MFDB_LedgerNumber DESC),0)
AS '91-120',
ISNULL((SELECT TOP 1 CAST(ND.MFDB_BalancePrincipal AS BIGINT )
FROM dbo.MFDB_NEW_DCB_REPORT ND
WHERE ND.MFDB_SHGId
= DR.MFDB_SHGId
AND ND.MFDB_ShgMemberId
= DR.MFDB_ShgMemberId
AND ND.MFDB_LoanNumber
= DR.MFDB_LoanNumber
AND DATEDIFF(Day,ND.MFDB_TxnDate,@i_AsOnDate) <= 180
AND DATEDIFF(Day,ND.MFDB_TxnDate,@i_AsOnDate) > 120
ORDER BY ND.MFDB_LedgerNumber DESC),0)
AS '121-180',
ISNULL((SELECT TOP 1 CAST(ND.MFDB_BalancePrincipal AS BIGINT )
FROM dbo.MFDB_NEW_DCB_REPORT ND
WHERE ND.MFDB_SHGId
= DR.MFDB_SHGId
AND ND.MFDB_ShgMemberId
= DR.MFDB_ShgMemberId
AND ND.MFDB_LoanNumber
= DR.MFDB_LoanNumber
AND DATEDIFF(Day,ND.MFDB_TxnDate,@i_AsOnDate) <= 365
AND DATEDIFF(Day,ND.MFDB_TxnDate,@i_AsOnDate) > 180
ORDER BY ND.MFDB_LedgerNumber DESC),0)
AS '181-365',
ISNULL((SELECT TOP 1 CAST(ND.MFDB_BalancePrincipal AS BIGINT )
FROM dbo.MFDB_NEW_DCB_REPORT ND
WHERE ND.MFDB_SHGId
= DR.MFDB_SHGId
AND ND.MFDB_ShgMemberId
= DR.MFDB_ShgMemberId
AND ND.MFDB_LoanNumber
= DR.MFDB_LoanNumber
AND DATEDIFF(Day,ND.MFDB_TxnDate,@i_AsOnDate) <= 689
AND DATEDIFF(Day,ND.MFDB_TxnDate,@i_AsOnDate) > 365
ORDER BY ND.MFDB_LedgerNumber DESC),0)
AS '366-689',
ISNULL((SELECT TOP 1 CAST(ND.MFDB_BalancePrincipal AS BIGINT )
FROM dbo.MFDB_NEW_DCB_REPORT ND
WHERE ND.MFDB_SHGId
= DR.MFDB_SHGId
AND ND.MFDB_ShgMemberId
= DR.MFDB_ShgMemberId
AND ND.MFDB_LoanNumber
= DR.MFDB_LoanNumber
AND DATEDIFF(Day,ND.MFDB_TxnDate,@i_AsOnDate) <= 730
AND DATEDIFF(Day,ND.MFDB_TxnDate,@i_AsOnDate) > 689
ORDER BY ND.MFDB_LedgerNumber DESC),0)
AS 'Above_2_Yrs'
FROM DBO.MFDB_NEW_DCB_REPORT DR
WHERE DR.MFDB_BranchId
= 67
AND DR.MFDB_SHGId
IN (5514)
AND DR.MFDB_ShgMemberId = 66735
AND DATEDIFF(DAY,MFDB_TxnDate,@i_AsOnDate) >= 0
SELECT * FROM CA1
results after the execution of the script:
SerialNumber
ShgId
ShgName
MemId
MemName
YETDUE
0-30
31-60
61-90
91-120
121-180
181-365
366-689
Above_2_Yrs
3
5514
MAHALAXMI-5514
SUNITA
10000
3636
2727
1818
909
0
0
0
0
2
5514
MAHALAXMI-5514
SUNITA
10000
3636
2727
1818
909
0
0
0
0
6
5514
MAHALAXMI-5514
SUNITA
10000
3636
2727
1818
909
0
0
0
0
4
5514
MAHALAXMI-5514
SUNITA
10000
3636
2727
1818
909
0
0
0
0
1
5514
MAHALAXMI-5514
SUNITA
10000
3636
2727
1818
909
0
0
0
0
5
5514
MAHALAXMI-5514
SUNITA
10000
3636
2727
1818
909
0
0
0
0
But I expected results is:
s.n
ShgId
ShgName
MemId
MemName
YETDUE
0-30
31-60
61-90
91-120
121-180
181-365
366-689
Above_2_Yrs
1
5514
MAHALAXMI-5514
66735
SUNITA
10000
909
1818
2727
3636
0
0
0
I want only one record per member with aging .. please advice me for further action. -
Stock Aging report in SAP Business One
Greetings,
I don't think this issue has been raised successfully on the forums (i checked, there's no real resolution at the moment).
The end user requires some form of stock aging that their auditors deem important but there's no such feature within SAP B1.
Their basic requirements would be:
Stock Code | Description | Date of Purchase | Current Month (qty) | 30-90 Days (qty) | 91-120 Days (qty) | 120 days and above (qty)
I'm wondering if this is even possible with the end user using multiple warehouses to stock their inventory, and some items are marked as serial items and others are marked as batch.
Any ideas?Thank you for pointing me in the right direction. Amended your query a little so the user input square brackets are there.
SELECT T0.ITEMCODE , T0.ONHAND as 'Total Qty', CASE WHEN Datediff(day, T1.LASTPURDAT,GETDATE())<45 THEN T0.ONHAND END '<45 Days(Qty)', CASE WHEN Datediff(day, T1.LASTPURDAT,GETDATE())<45 THEN T0.ONHAND*T0.AVGPRICE END '<45 Days(Value)', CASE WHEN DateDiff(day, T1.LASTPURDAT,GETDATE()) >= 45 AND DateDiff(day, T1.LASTPURDAT,GETDATE()) < 90 THEN T0.ONHAND END '45 to 90 Days(Qty)' , CASE WHEN DateDiff(day, T1.LASTPURDAT,GETDATE()) >= 45 AND DateDiff(day, T1.LASTPURDAT,GETDATE()) < 90 THEN T0.ONHAND*T0.AVGPRICE END '45 to 90 Days(Value)', CASE WHEN Datediff(day, T1.LASTPURDAT,GETDATE()) >= 90 THEN T0.ONHAND END '>90 Days(Qty)', CASE WHEN Datediff(day, T1.LASTPURDAT,GETDATE()) >= 90 THEN T0.ONHAND*T0.AVGPRICE END '>90 Days(Value)'
FROM OITW T0 INNER JOIN OITM T1 ON T0.ITEMCODE = T1.ITEMCODE INNER JOIN OITB T2 ON T1.ITMSGRPCOD=T2.ITMSGRPCOD WHERE T0.ONHAND>0 AND T0.WhsCode ='[%0]'
AND T2.ITMSGRPNAM = [%2]
Will continue to review the aging issue and maybe even update the forums with the results.
I can understand why in the query you've provided above its not really feaseable to have the Date of Purchase because its showing the stock quantity in total (which would make more sense instead of each item row by row)
Edited by: Davinder Singh on Apr 18, 2008 4:38 PM -
Hello,
I want to create pie chart report which will display bug counts according to their age i.e. within last month, 1-3 month old and 3+ month ago.
I have got dataset (TFS2010Olap as data source) which is displaying 2 columns, System_CreatedDate and WorkItem_count. I want to create group expression at chart level so it categories
source data and display on chart accordingly.
I am using this expression in categoryGroup of pie chart:
=iif(CDate(Fields!System_CreatedDate.Value) > DateAdd("m", -1, now), "Within Previous Month", iif(CDate(Fields!System_CreatedDate.Value) > DateAdd("m", -3, now), "1-3 Months Old", "3+ Months Old"))
but I am getting error: Conversion from string "22/01/2012" to type "Date" is not valid. I tried to do with function
"DateDiff" but getting same error. Please let me know what I am missing or wrong in the expression? I had a look at MSDN post with title "SSRS
Report to calculate Bug Age" but getting this date conversion problem.
I tried to format date as well but getting format error again:
=iif(cdate(format((Fields!System_CreatedDate.Value),"dd/MM/yyyy")) > format(DateAdd("m", -1, now),"dd/MM/yyyy"), "Within Previous Month",
iif(cdate(format((Fields!System_CreatedDate.Value),"dd/MM/yyyy")) > format(DateAdd("m", -3, now),"dd/MM/yyyy"), "1-3 Months Old", "3+ Months Old"))Hi gajeshm,
I have tested on my local environment and can reproduce the issue, the issue caused by the format of the
System_CreatedDate which is "dd/MM/yyyy" and not supportted as the date type in the report but instead of string type. You need to convert this field to the string format "MM/dd/yyyy" and then using the CDate()
function to change it the Date type (because the format "dd/MM/yyyy" which is not support to use directly in the CDate() function, so we need to change it to "MM/dd/yyyy" using the split() function and this format will support to use in
the CDate() function).
Details information below for your reference:
Right click the dateset to add calculated field(NewSystem_CreateDate) and use expression as below, this calculated field will display the NewSystem_CreateDate which is the datetype and format is "MM/dd/yyyy":
=Cdate(split(Fields!System_CreatedDate.Value,"/")(1) &"/"& split(Fields!System_CreatedDate1.Value,"/")(0)&"/"&split(Fields!System_CreatedDate.Value,"/")(2))
Modify the first expression you have provided and change the "System_CreatedDate" to the Calculated field "System_CreatedDate":
=iif(Fields!NewSystem_CreatedDate.Value> DateAdd("m", -1, now), "Within Previous Month", iif(Fields!NewSystem_CreatedDate.Value > DateAdd("m", -3, now), "1-3 Months Old", "3+ Months Old"))
If you still have any problem, please feel free to ask.
Regards,
Vicky Liu
If you have any feedback on our support, please click
here.
Vicky Liu
TechNet Community Support -
Hello Experts !!!!
My Client requires a Stock Age analysis report .
It is a trading company of steel .
my client wants to know that how old my stock is in warehouse or how much is 30 days old ,60 days old ,90 days old.
Below is my query
SELECT T0.ITEMCODE , T0.DSCRIPTION,T2.U_WT,SUM(T0.QUANTITY)AS QUANTITY,T1.DOCDATE,
CASE WHEN Datediff(day, T1.DOCDATE,GETDATE())<30 THEN SUM(T0.QUANTITY) END '<30 Days(Qty)',
CASE WHEN Datediff(day, T1.DOCDATE,GETDATE())<30 THEN SUM(T0.QUANTITY)*T2.U_WT END '<30 Days(MT)',
CASE WHEN Datediff(day, T1.DOCDATE,GETDATE())>30 AND Datediff(day, T1.DOCDATE,GETDATE())<60 THEN SUM(T0.QUANTITY) END '<60 Days(Qty)',
CASE WHEN Datediff(day, T1.DOCDATE,GETDATE())>30 AND Datediff(day, T1.DOCDATE,GETDATE())<60 THEN SUM(T0.QUANTITY)*T2.U_WT END '<60 Days(MT)',
CASE WHEN Datediff(day, T1.DOCDATE,GETDATE())>60 AND Datediff(day, T1.DOCDATE,GETDATE())<90 THEN SUM(T0.QUANTITY) END '<90 Days(Qty)',
CASE WHEN Datediff(day, T1.DOCDATE,GETDATE())>60 AND Datediff(day, T1.DOCDATE,GETDATE())<90 THEN SUM(T0.QUANTITY)*T2.U_WT END '<90 Days(MT)',
CASE WHEN Datediff(day, T1.DOCDATE,GETDATE())>90 AND Datediff(day, T1.DOCDATE,GETDATE())<120 THEN SUM(T0.QUANTITY) END '<120 Days(Qty)',
CASE WHEN Datediff(day, T1.DOCDATE,GETDATE())>90 AND Datediff(day, T1.DOCDATE,GETDATE())<120 THEN SUM(T0.QUANTITY) END '<120 Days(MT)'
FROM PDN1 T0 INNER JOIN OPDN T1 ON T0.DOCENTRY =T1.DOCENTRY INNER JOIN OITM T2 ON T0.ITEMCODE=T2.ITEMCODE
GROUP BY T0.ITEMCODE , T0.DSCRIPTION,T1.DOCDATE,T2.U_WT
but problem is that i am able to track when goods were arrived in warehouse .But i am enable to track how much went out warehouse.
" MY CLIENT WANTS THE REPORT GOODS RECEIPT NOTE WISE REPORT. " that how much qty has been delivered against a particular Goods receipt note. But we havn't provided any reference to delivery of goods receipt note .
Experts Thanx in advance.
Krishna VamsiHello Krishna Vamsi,
Try this:
SELECT T1.ITEMCODE,T1.ItemName,T1.U_WT,SUM(IsNull(T0.INQty,0)-IsNull(T0.OutQty,0)) AS QUANTITY,T0.DOCDATE,
CASE WHEN Datediff(dd, T0.DOCDATE,GETDATE())<30 THEN SUM(IsNull(T0.INQty,0)-IsNull(T0.OutQty,0)) END '<30 Days(Qty)',
CASE WHEN Datediff(dd, T0.DOCDATE,GETDATE())<30 THEN SUM(IsNull(T0.INQty,0)-IsNull(T0.OutQty,0))*T1.U_WT END '<30 Days(MT)',
CASE WHEN Datediff(dd, T0.DOCDATE,GETDATE())>30 AND Datediff(dd, T0.DOCDATE,GETDATE())<60 THEN SUM(IsNull(T0.INQty,0)-IsNull(T0.OutQty,0)) END '<60 Days(Qty)',
CASE WHEN Datediff(dd, T0.DOCDATE,GETDATE())>30 AND Datediff(dd, T0.DOCDATE,GETDATE())<60 THEN SUM(IsNull(T0.INQty,0)-IsNull(T0.OutQty,0))*T1.U_WT END '<60 Days(MT)',
CASE WHEN Datediff(dd, T0.DOCDATE,GETDATE())>60 AND Datediff(dd, T0.DOCDATE,GETDATE())<90 THEN SUM(IsNull(T0.INQty,0)-IsNull(T0.OutQty,0)) END '<90 Days(Qty)',
CASE WHEN Datediff(dd, T0.DOCDATE,GETDATE())>60 AND Datediff(dd, T0.DOCDATE,GETDATE())<90 THEN SUM(IsNull(T0.INQty,0)-IsNull(T0.OutQty,0))*T1.U_WT END '<90 Days(MT)',
CASE WHEN Datediff(dd, T0.DOCDATE,GETDATE())>90 AND Datediff(dd, T0.DOCDATE,GETDATE())<120 THEN SUM(IsNull(T0.INQty,0)-IsNull(T0.OutQty,0)) END '<120 Days(Qty)',
CASE WHEN Datediff(dd, T0.DOCDATE,GETDATE())>90 AND Datediff(dd, T0.DOCDATE,GETDATE())<120 THEN SUM(IsNull(T0.INQty,0)-IsNull(T0.OutQty,0)) END '<120 Days(MT)'
FROM dbo.OINM T0
INNER JOIN dbo.OITM T1 ON T0.ITEMCODE=T1.ITEMCODE
GROUP BY T1.ITEMCODE,T1.ItemName,T0.DOCDATE,T1.U_WT
Thanks,
Gordon -
Detailed Aging Report from SAP B1 v2007A
Hello all,
I have SAP Business One v 2007 A in my company. The auditors are coming in next week and I was trying to get the Aging report for both vendor and customer. The default summary looks good. To get the details, I have to go into each customer/vendor and collect them. Is there a way to get all the details in one shot (like an executing an SQL)?
Thank you all so much.
Manoj.Hello Manoj - maybe try this since it uses the actual General Journal entries found in the JDT1 table. PS - I have no idea why it does not show the NOT EQUAL characters of < and > in the last CASE. The CASE calculation should be the same in all instances - make sure you add that before running. I used the appropriate coding for the SQL - something about SAP forums!!!
For Vendors, just change the CardType to S in the WHERE clause, the Transtype, and change the column headings to what you want them to say.
Hope this helps...
Regards - Zal
--F-BP AR Aging Report Detail Ver 1 ZP 2011 04 16
--DESCRIPTION: SQL uses General Ledger Detail to create an Aging Report which shows
actual invoices, credit memos, and payments by reference date in the JDT1 table.
--AUTHOR(s):
--Version 1 Zal Parchem 16 April 2011
SELECT
T1.CardCode AS 'Cust Num',
T1.CardName AS 'Cust Name',
T0.SysDeb AS 'Debit Amt',
T0.SysCred * -1 AS 'Credit Amt',
CASE
WHEN T0.TransType = 13 THEN 'AR Invoice'
WHEN T0.TransType = 14 THEN 'AR Cred Memo'
WHEN T0.TransType = 24 THEN 'Payment'
ELSE 'Other'
END AS 'Trans Type',
T0.Ref1 AS 'Reference',
FcCurrency AS 'Currency',
CONVERT(VARCHAR(10), RefDate, 103) 'Posting Date',
CONVERT(VARCHAR(10), DueDate, 103) 'Due Date',
CONVERT(VARCHAR(10), TaxDate, 103) 'Doc Date' ,
CASE
WHEN (DATEDIFF(DD,RefDate,Current_Timestamp)) +1 < 31 THEN
CASE
WHEN SysCred < > 0 THEN SysCred * -1
ELSE SysDeb
END
END AS '0-30 Days',
CASE
WHEN (DATEDIFF(DD,RefDate,Current_Timestamp)) +1 > 30
AND (DATEDIFF(DD,RefDate,Current_Timestamp)) +1 < 61 THEN
CASE
WHEN SysCred < > 0 THEN SysCred * -1
ELSE SysDeb
END
END AS '31 to 60 Days',
CASE
WHEN (DATEDIFF(DD,RefDate,Current_Timestamp)) +1 > 60
AND (DATEDIFF(DD,RefDate,Current_Timestamp)) +1 < 91 THEN
CASE
WHEN SysCred < > 0 THEN SysCred * -1
ELSE SysDeb
END
END AS '61 to 90 days',
CASE
WHEN (DATEDIFF(DD,RefDate,Current_Timestamp)) +1 > 90
AND (DATEDIFF(DD,RefDate,Current_Timestamp)) +1 < 121 THEN
CASE
WHEN SysCred < > 0 THEN SysCred * -1
ELSE SysDeb
END
END AS '90 to 120 Days',
CASE
WHEN (DATEDIFF(DD,RefDate,Current_Timestamp)) +1 > 120
THEN
CASE
WHEN SysCred != 0 THEN SysCred * -1
ELSE SysDeb
END
END AS '120 Plus Days'
FROM JDT1 T0
INNER JOIN OCRD T1
ON T0.ShortName = T1.CardCode
AND T1.CardType = 'C'
WHERE
T0.IntrnMatch = '0'
AND T0.BalDueDeb != T0.BalDueCred
ORDER BY
T1.CardCode,
T0.TaxDate
FOR BROWSE -
Customer Aging Report Query (without invoices offset by incoming payment)
Hi All Experts,
May I know is there any field from JDT1 mention which invoices is already offset by the Incoming payment or AR Credit note? Because I do not want those invoices that already offset by incoming payment appear at the Customer Aging Report. Meaning, the data appear in the Customer Aging Report is only show those invoices that yet to pay by the customer. Kindly give some advise on it. Thanks a lot.
Thanks and regards,
Angie NgHi David,
Thanks for your suggestion. I have try it, but all of my JDT1.IntrnMatch is in 0 value. Meaning in my situation it is none of any reconcilliation making. But from my SBO window, i manage to see that actually this incoming payment is pay for which invoices. Problem is it is difficult for me to do the possiblity logic that might be happen in my Customer Aging Report Query. Please give some advise that how to show only those invoices yet to pay? The current query will show all the data no matter the invoices or credit memo has been offset.
select OCRD.cardcode 'Supplier Code',OCRD.cardname 'Name',sysdeb 'Debit GBP',syscred 'Credit GBP',
case JDT1.transtype
when '13' then 'INV'
when '14' then 'AR CN'
when '24' then 'INCOMING'
else 'Other'
end 'Type',
Ref1,
fccurrency 'BP Currency',
CONVERT(VARCHAR(10), refdate, 103)'Posting Date' ,
CONVERT(VARCHAR(10), duedate, 103) 'Due Date',
CONVERT(VARCHAR(10), taxdate, 103) 'Doc Date' ,
CASE
when (DATEDIFF(dd,refdate,current_timestamp))+1 < 31
then
case
when syscred <> 0 then syscred * - 1
else sysdeb
end
end "0-30 days",
case when ((datediff(dd,refdate,current_timestamp))+1 > 30
and (datediff(dd,refdate,current_timestamp))+1< 61)
then
case
when syscred <> 0 then syscred * - 1
else sysdeb
end
end "31 to 60 days",
case when ((datediff(dd,refdate,current_timestamp))+1 > 60
and (datediff(dd,refdate,current_timestamp))+1< 91)
then
case
when syscred <> 0 then syscred * - 1
else sysdeb
end
end "61 to 90 days",
CASE
when (DATEDIFF(dd,refdate,current_timestamp))+1 > 90
then
case
when syscred= 0 then sysdeb
when sysdeb= 0 then syscred * - 1
end
end "90 + days"
from JDT1,OCRD where JDT1.shortname = OCRD.cardcode and cardtype = 'c' and intrnmatch = '0'
ORDER BY OCRD.CARDCODE, taxdate
Maybe you are looking for
-
FOR LOOP cursor that updates table A based on a value in table B
Hi, I need a FOR LOOP cursor that scans and updates all pro-rata column in table EMPLOYEE(child) based on what pay classification all employees are on in the CLASSIFICATION(parent) table. DECLARE BEGIN IF employee.emp_type = 'FT' THEN UPDATE employee
-
need help what to do if anything
-
Oracle Developer Day Jdeveloper 10g early access not work
Oracle Developer Day Workshop Materials Creating Persistence Services Using Toplink and POJOs I use Jdeveloper 10 ea : To create a new workspace with a new project for the model Application Name EmployeeRequisitionApplication Directory Name <JDEV_HOM
-
Where is the PhotoShop subscription that I purchased ?
I just paid for my subscription. Where is it ? There is no link, download, or receipt. What happened. How long do I have to wait ?
-
Finder: Safari Community Toolbar Issue
While searching through Finder I will almost always receive a pop-up window that is titles "Community Toolbar" It then proceeds to inform me that the Safari I am currently running is out of date and the toolbar cant be opened. However everything on t