Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: dateadd in sql Post Reply Post New Topic
Author Message
juliesabre
Newbie
Newbie


Joined: 05 Nov 2015
Online Status: Offline
Posts: 2
Quote juliesabre Replybullet Topic: dateadd in sql
    Posted: 09 Nov 2015 at 11:38pm
Hi
Can someone advise please - I am new to crystal reports and sql - how do you write a DATEADD formula in sql like you do in crystal reports. below is the formula I have done in Crystal reports to enable due dates from invoice dates based on invoice terms

Thanks in advance

Hi
New to the forum and new to Crystal Reporting - I know this question isn't entirely about Crystal reports but can anyone help - I have put a formula in Crystal using the DATEADD function to calculate due dates of debtors based on the payment terms. This is fine in Crystal but I wondered - does anyone now how to get this formula into SQL so I can import the SQL view to excel rather than export the crystal report to excel.
the formula is as follows:-

if{ArInvoice.TermsCode} = "01" then dateadd('m',3,{ArInvoice.InvoiceDate}) - day(dateadd('m',3,{ArInvoice.InvoiceDate})) else if{ArInvoice.TermsCode} = "10" then dateadd('m',2,{ArInvoice.InvoiceDate}) - day(dateadd('m',2,{ArInvoice.InvoiceDate})) else if {ArInvoice.TermsCode} = "02" then dateadd("d",60,{ArInvoice.InvoiceDate}) else if {ArInvoice.TermsCode} = "03" then dateadd("d",30,{ArInvoice.InvoiceDate}) else if {ArInvoice.TermsCode} = "04" then {ArInvoice.InvoiceDate} else if{ArInvoice.TermsCode} = "9" then dateadd('d',(-(DAY(dateadd('m',1,dateadd('d',30,{ArInvoice.InvoiceDate}))))+15),dateadd('m',1,dateadd('d',30,{ArInvoice.InvoiceDate}))) else if {ArInvoice.TermsCode} = "12" then dateadd("d",90,{ArInvoice.InvoiceDate})

Thanks

juliesabre
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 16 Nov 2015 at 4:45am
I am assuming it is MS-SQL. Check this link https://msdn.microsoft.com/en-us/library/ms186819.aspx
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.