We help IT Professionals succeed at work.

How to update Date column of sysbase IQ database Table

4,341 Views
Last Modified: 2014-05-04
Hi,

This question I asked in this page earlier,
https://www.experts-exchange.com/OS/Unix/Q_28425882.html


I have Sybase iq Table Name dates_col in that I have column name DATE_BD whose
data stucture:
column_name: DATE_BD4
domain_name:date
width:4
scale:0
nulls:N

update  temp_table
set DATE_BD4= getdate()
WHERE PROCESS_MONTH        = 'MAR'
AND   PROCESS_YEAR        = 2014;
This works and updates DATE_BD4 with current date.

But I am only able to set to current date today's date to that column, is there is any way I can update any other value like tomorrow's date for that
column like below.

update  temp_table
set dateformat(DATE_BD4,'MM/DD/YYYY') = '05/05/2014'
WHERE PROCESS_MONTH        = 'MAR'
AND   PROCESS_YEAR        = 2014;
commit;

But I am getting the following error
> Script lines: 1-5 --------------------------
 SQL Anywhere Error -131: Syntax error near '=' on line 2
 Msg: 102, Level: 15, State: 0
 Line: 0

How can I update other dates by giving the value to the column directly.
https://www.experts-exchange.com/OS/Unix/Q_28425882.html


I want to assign any date to it, what I mean is here

update  temp_table
DATE_BD4 = '05/05/2014'
WHERE PROCESS_MONTH        = 'MAR'
AND   PROCESS_YEAR        = 2014;
commit;

DATE_BD4  can be,
DATE_BD4 = '05/05/2014'
DATE_BD4 = '10/07/2001'
DATE_BD4 = '03/05/1999'
DATE_BD4 = '09/07/2017'
DATE_BD4 = '08/25/2014'

etc you are functions might not happen in this case, I want the correct syntax where I can execute the update statement to set date column for any date value.

I am doing testing for this table, I will re-assign values as and when my testing is complete.

Thanks,
Sailaja
Comment
Watch Question

GanapathiFacets Developer

Commented:
Your below query will not work as the 2nd has a syntax error. You cannot use like that.

update  temp_table
set dateformat(DATE_BD4,'MM/DD/YYYY') = '05/05/2014'
WHERE PROCESS_MONTH        = 'MAR'
AND   PROCESS_YEAR        = 2014;

You can create a variable and pass it to the UPDATE statement, like below.

declare @mydate DATETIME
SET @mydate = '05/05/2014'

update  temp_table
DATE_BD4 = @mydate
WHERE PROCESS_MONTH        = 'MAR'
AND   PROCESS_YEAR        = 2014;

Open in new window

Is that what you are looking for?

Author

Commented:
For this query the ouptu Error
update  temp_table
set dateformat(DATE_BD4,'MM/DD/YYYY') = '05/05/2014'
WHERE PROCESS_MONTH        = 'MAR'
AND   PROCESS_YEAR        = 2014;


> Script lines: 1-4 --------------------------
 SQL Anywhere Error -131: Syntax error near '=' on line 2
 Msg: 102, Level: 15, State: 0
 Line: 0

For second declare worked but SET didn't work.

SET @mydate = '05/05/2014'


> Script lines: 1-1 --------------------------
 SQL Anywhere Error -260: Variable '@mydate' not found
 Msg: 137, Level: 15, State: 0
 Line: 0

Thanks,
Sailaja
GanapathiFacets Developer

Commented:
use SELECT instead of SET.

SELECT @mydate = '05/05/2014'

Author

Commented:
declare @mydate DATETIME
 Command was executed successfully

SELECT @mydate = '05/05/2014'

> Script lines: 1-1 --------------------------
 SQL Anywhere Error -260: Variable '@mydate' not found
 Msg: 137, Level: 15, State: 0
 Line: 0
GanapathiFacets Developer

Commented:
You need to execute both the variable assignment(SELECT) and UPDATE statements together.

Author

Commented:
update  temp_table
set dateformat(DATE_BD4,'MM/DD/YYYY') = SELECT @mydate = '05/05/2014'
WHERE PROCESS_MONTH        = 'MAR'
AND   PROCESS_YEAR        = 2014;

> Script lines: 1-7 --------------------------
 SQL Anywhere Error -131: Syntax error near '=' on line 2
 Msg: 102, Level: 15, State: 0
 Line: 0

Please give the full update and select combination.

Thanks,
Sailaja
Facets Developer
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks a lot this worked.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.