Solved

SQL-Server and Informix

Posted on 2001-08-01
8
3,213 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
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…

744 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

15 Experts available now in Live!

Get 1:1 Help Now