Solved

Date_Add or Date_Sub

Posted on 2012-03-20
3
829 Views
Last Modified: 2012-06-22
I am trying to add an expression to a BI container.
DATE_ADD(ARVLDATE,INTERVAL 2 DAY)
this continues to return an error of "incorrect syntax near '2'
screen shots attached
0
Comment
Question by:actsoft
3 Comments
 
LVL 34

Expert Comment

by:James0628
ID: 37745877
I don't know if I can help, but FWIW:

 I don't see any screenshots, or anything else, attached to your post.

 You posted this in the MS SQL section.  Is DATE_ADD an MS SQL function?  It wasn't in the past, but maybe it's been added.  From a little searching I did, DATE_ADD seems to be a MySQL function, so maybe this should be in the MySQL zone?

 Apart from that, your syntax seems OK, so I don't know why you'd be getting an error.  I assume that ARVLDATE is a date or datetime column, and if it wasn't, I'd expect an error on that, not the 2.

 Any chance you're using MS SQL and actually using DATEADD, instead of DATE_ADD?  The DATEADD arguments would be:
 
DATEADD(day, 2, ARVLDATE)

 James
0
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 37747073
If  you are using mysql as James indicated, then the syntax you are using should work.

If however, you are using SQL Server, then date_add is not a valid sql server syntax.

dateAdd(day, 2, ARVLDATE)
0
 
LVL 16

Accepted Solution

by:
vdr1620 earned 500 total points
ID: 37747314
I believe you are using a MYSQL syntax..which is different from MS SQL Syntax

Now, In which BI container are you trying to use this function ? unless you are trying to use this in a ADO.NET source container connected to MYSQL database.. in which case syntax seems to be correct.. If the below does not work,post error msg or screen shot of the error

try this

DATEADD("DD",2,ARVLDATE) -- if you are using it as an expression in SSIS

OR

DATEADD(DD,2,ARVLDATE) -- If you are using it in a SQL Query
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question