Solved

Date_Add or Date_Sub

Posted on 2012-03-20
3
857 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 35

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: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
T-SQL: Only Wanting One Record 8 54
EF5 How do I stop pre-compiled views? 8 46
Creating a View from a CTE 15 36
Migrate SQL 2005 DB to SQL 2016 4 18
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

742 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