Solved

SQL-Server and Informix

Posted on 2001-08-01
8
3,360 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
[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
  • 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
Industry Leaders: 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!

 
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

724 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