Solved

SQL-Server and Informix

Posted on 2001-08-01
8
3,316 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL log file keeps growing despite getting successful log backups 4 59
SQL Server memory sizing - reallocation 16 86
Question about DB Schema 27 67
Merging spreadsheets 8 65
This article describes some very basic things about SQL Server filegroups.
SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
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…

685 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