Solved

SQL-Server and Informix

Posted on 2001-08-01
8
3,267 Views
Last Modified: 2012-05-04
Is there any equalant function function in informix like  dateadd("mm","3",getdate()) in squal server????

I need a function which returns a prior date depending on my requirement, for example a date 30 days ago,  a date 2 weeks ago.....

Hope you help me..
0
Comment
Question by:vinaykn
  • 4
  • 3
8 Comments
 
LVL 18

Expert Comment

by:nigelrivett
ID: 6344621
dateadd(dd,-30,getdate())
dateadd(ww,-1,getdate())
0
 
LVL 1

Expert Comment

by:Greyman
ID: 6354329
Or (in Informix), you could do this:

value = current - 30 units day

value = current - 1 units month

or in a comparison:
(current - value) > 5 units day

(Note that 'value' is some arbitrary date-related column, while 'current' is the keyword 'current' - you dould use 'today' instead, depending on your needs.)

HTH
0
 

Author Comment

by:vinaykn
ID: 6354373
Is this related to a simple query, or a procedure?
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 1

Accepted Solution

by:
Greyman earned 50 total points
ID: 6354383
You could do that in a simple query:

insert into mytable(col1, col2) values ('Abc', current - 5 units day)

or in a stored procedure, just like any other mathematical operation.

let myvar = current - 10 units day;
0
 

Author Comment

by:vinaykn
ID: 6354400
Thanks.Really it helps me.. But still i do have problem, may not relates this question scope.  The same sql query i am able to from from informix directly, but when i pass this from java program, through jdbc, its throwing sql exception.   What could be the problem? Is it because of jdbc driver not handling properly?????I am going to accept ur comment as answer. :-) :-)
0
 

Author Comment

by:vinaykn
ID: 6354406
is current return date datatype or datetime datatype. Could it be any problem?
0
 
LVL 1

Expert Comment

by:Greyman
ID: 6354409
I'm not sure but you could put the whole thing in brackets and put AS DATE or AS DATETIME at the end to force it from one to the other.

The other thing you could do is add or subtract an INTERVAL instead, but the syntax for that is a real pain.  (Have a look in Informix Answers OnLine at the INTERVAL keyword.)
0
 

Author Comment

by:vinaykn
ID: 6354423
Thanks for ur help. If you are still interested, continue writing on my problem...
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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to get sum of group by column and sum of total values 4 68
Powershell script 13 101
VBA MS Word "Table of Contents" extractor` 4 41
SQL SELECT query help 7 37
APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

770 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