473,386 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Informix Date Function Equivalent

Hello. I have an Informix SQL statement that I need to run in MS SQL
Server. When I try to execute it I get the following error message from
Query Analyzer:

Server: Msg 195, Level 15, State 10, Line 4
'date' is not a recognized function name.

Can anyone help me convert this informix sql statement into and MS Sql
Statement? Here is the query I have:

select
a.comp_code,
a.comp_date,
case when date(date(date(comp_date - day(comp_date) +1) - 2 units
month) - 1 units day) < b.inception_date then b.inception_date
else date(date(date(comp_date - day(comp_date) +1) - 2 units month) - 1
units day)
end prior_date,
a.net_return,
a.net_uv,
a.gross_return,
a.gross_uv,
a.estimated_flag
from composite_perf a, composite_detail b
where
(month(a.comp_date) in (3,6,9,12) or a.comp_date = b.inception_date)
and a.comp_code = 'AEU'
and a.comp_code = b.comp_code
into #tmp_composite_data

Thanks in advance.

Jul 23 '05 #1
4 16719
It might have helped if you'd told us what DATE actually does here. It
looks like date arithmetic so take a look at DATEADD and DATEDIFF in
Books Online.

--
David Portas
SQL Server MVP
--

Jul 23 '05 #2
The DATE function takes as input a non-DATE value such as CHAR,
DATETIME, or INTEGER and returns the corresponding DATE value.

Jul 23 '05 #3
Figured it out using the DATEADD function.

case when
DateAdd(day,-1,(DateAdd(month,-2,(DateAdd(day,1,(DateAdd(day,-day(comp_date),comp_date)))))))
< b.beg_date then b.beg_date
else
DateAdd(day,-1,(DateAdd(month,-2,(DateAdd(day,1,(DateAdd(day,-day(comp_date),comp_date)))))))

Jul 23 '05 #4
On 20 May 2005 10:06:37 -0700, Matt wrote:
The DATE function takes as input a non-DATE value such as CHAR,
DATETIME, or INTEGER and returns the corresponding DATE value.


The equivalent of this would be CONVERT:

convert(datetime,'2005-05-14')

But you'd still need dateadd/datediff to do the date arithmetic.

One of the interesting, if convoluted, uses for convert with dates is to
group by an unusual time period. For instance, this would produce a summary
by 6-hour shifts:

SELECT ShiftStart, count(*)
FROM (
SELECT convert(datetime,
floor(convert(float, EntryTime) * 4) / 4) as ShiftStart
FROM Entries
WHERE EntryTime IS NOT NULL
) AS RoundedEntries
GROUP BY ShiftStart
ORDER BY ShiftStart

I tried using 3 instead of 4, but ran into rounding errors: instead of
16:00:00 I was getting 15:59:59.997.
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: D. Sandmann | last post by:
I have had this problem in the past on another machine and fixed it by setting the environment variables for INFORMIXDIR and INFORMIXSERVER. When adding the same lines on the new machine I still...
4
by: webmaster | last post by:
Hi, I'm desperatly trying to use Kinfxdb, but I have numerous segmentation faults, who lead my Zope to crash. It mostly occurs when I try to work with "date" fields (with an Informix Online...
0
by: Rajiv Jhaveri | last post by:
Folks, In INFORMIX there is a default value called DBSERVERNAME that can be assigned to a column during the table definition as follows: create table t1 (c1 char(18) default DBSERVERNAME ); ...
1
by: Matt | last post by:
I would like to convert a couple informix stored procedures to SQL Server stored procedures. I have no idea how to accomplish this. Here is an example of one of the procedures I need to convert. ...
10
by: Joachim Banzhaf | last post by:
Hi, Creating the federated datasource library for informix fails for me. The db2 server is version 8.1 WSE on AIX 4.3. The informix client on this server is version CSDK 2.81/ESQL 9.53 UC2....
0
by: Lester Knutsen | last post by:
Washington Area IBM Informix/DB2 User Group meeting - June 7, 2005 -------------------------------------------------------------- Mark the date, our next user group meeting will be another...
3
by: Rodolfo | last post by:
Hi everybody! I'm working on a migration from Informix to SQL Server... I'm doing it through DTS and ODBC. What I'm doing is using the DTS, my data origin is tha Informix database and mi...
4
by: rick | last post by:
hi Is there a DB2 equivalent of Informix.Extend function? or please help me the best way to create one Thanks rick
14
by: Khan | last post by:
Hello, I want to connect my intranet server (with php/apache) to the other informix database server, But I didnt it. I dont know how i can do it? Can i use php_informix extensions for example...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.