Solved

Date_Add or Date_Sub

Posted on 2012-03-20
3
809 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how the fundamental information of how to create a table.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now