[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Date_Add or Date_Sub

Posted on 2012-03-20
3
Medium Priority
?
905 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 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 29

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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

872 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