Link to home
Start Free TrialLog in
Avatar of vinaykn
vinaykn

asked on

SQL-Server and Informix

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..
Avatar of nigelrivett
nigelrivett

dateadd(dd,-30,getdate())
dateadd(ww,-1,getdate())
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
Avatar of vinaykn

ASKER

Is this related to a simple query, or a procedure?
ASKER CERTIFIED SOLUTION
Avatar of Greyman
Greyman

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vinaykn

ASKER

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. :-) :-)
Avatar of vinaykn

ASKER

is current return date datatype or datetime datatype. Could it be any problem?
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.)
Avatar of vinaykn

ASKER

Thanks for ur help. If you are still interested, continue writing on my problem...