Print Page | Close Window

dateadd in sql

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=21768
Printed Date: 03 May 2024 at 6:43pm


Topic: dateadd in sql
Posted By: juliesabre
Subject: dateadd in sql
Date 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



Replies:
Posted By: kevlray
Date 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



Print Page | Close Window