![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
= '03/12/2010 13:01.000', but I don't know how to do it with these three columns. And, you can't just do WHERE item_date >= '03/12/10' |
#2
| |||
| |||
|
|
We have a vendor product and in their informix database, they have their date, time and seconds separated in 3 different columns. item_date (date field) item_time (smallint field) item_seconds (smallint field) Sample data: 03/12/10 41 1303 (Ie... 03/12/10 00:41:13.03) 03/12/10 330 4900 (Ie... 03/12/10 03:30:49.00) 03/12/10 710 1001 (Ie... 03/12/10 07:10:10.01) 03/12/10 1336 3300 (Ie... 03/12/10 13:36:33.00) My question is... I want to be able to pass in a Date, Time and Seconds and only get records after that specific time. In a normal database, I would just say, SELECT * FROM MYTABLE WHERE EventDateTime = '03/12/2010 13:01.000', but I don't know how to do it with these three columns. And, you can't just do WHERE item_date >= '03/12/10' and item_time >= '1244' and item_seconds >= '1100' A guy I work with said I should try to convert the tree columns to a julian date and then compare the julian dates. |
#3
| |||
| |||
|
|
On Fri, Mar 12, 2010 at 14:43, J. Hart <unleashedman... (AT) gmail (DOT) com> wrote: We have a vendor product and in their informix database, they have their date, time and seconds separated in 3 different columns. item_date (date field) item_time (smallint field) item_seconds (smallint field) Sample data: 03/12/10 * * * *41 * * *1303 * *(Ie... 03/12/10 00:41:13.03) 03/12/10 * * * *330 * * 4900 * *(Ie... 03/12/10 03:30:49.00) 03/12/10 * * * *710 * * 1001 * *(Ie... 03/12/10 07:10:10.01) 03/12/10 * * * *1336 * *3300 * *(Ie... 03/12/10 13:36:33.00) My question is... I want to be able to pass in a Date, Time and Seconds and only get records after that specific time. *In a normal database, I would just say, SELECT * FROM MYTABLE WHERE EventDateTime = '03/12/2010 13:01.000', but I don't know how to do it with these three columns. *And, you can't just do WHERE item_date >= '03/12/10' and *item_time >= '1244' and item_seconds >= '1100' A guy I work with said I should try to convert the tree columns to a julian date and then compare the julian dates. Ugh. *Talk about deliberately making everyone's life hard! Assuming the parameters are value_date, value_time and value_seconds, the basic structure of the condition is: * * WHERE ((value_date < item_date) OR * * * * * * * * * * (value_date = item_date AND value_time < item_time) OR * * * * * * * * * * (value_date = item_date AND value_time = item_time AND value_seconds < item_seconds)) -- Jonathan Leffler * * * * * * * * * #include <disclaimer..h Email: jleff... (AT) earthlink (DOT) net, jleff... (AT) us (DOT) ibm.com Guardian of DBD::Informix v2008.0513 --http://dbi.perl.org/ "Blessed are we who can laugh at ourselves, for we shall never cease to be amused." NB: Please do not use this email for correspondence. I don't necessarily read it every week, even. |
#4
| |||
| |||
|
|
From: superboer7 (AT) t-online (DOT) de Subject: Re: Comparing by Date, Time & Seconds columns Date: Mon, 15 Mar 2010 01:15:53 -0700 To: informix-list (AT) iiug (DOT) org i would build an spl for it... it aint pretty check the manual for improvements..., here goes; CREATE FUNCTION convittodatetime( thedate DATE, thehourminute SMALLINT, thesecconds SMALLINT) RETURNING datetime YEAR TO FRACTION(2) WITH (not variant); DEFINE f_hours SMALLINT; DEFINE c_hours CHAR(2); DEFINE f_minutes smallint; DEFINE c_minutes CHAR(2); DEFINE f_secs SMALLINT; DEFINE c_secs CHAR(2); DEFINE f_fractionsecs SMALLINT; DEFINE c_fractionsecs CHAR(2); DEFINE f_datepiece char(10); DEFINE retvalue DATETIME YEAR TO FRACTION(2); ON EXCEPTION RETURN "1970-01-01 00:00:00.0"; END EXCEPTION; LET f_datepiece = thedate :: DATETIME YEAR TO DAY :: char(20); LET f_minutes = mod(thehourminute,100); IF f_minutes > 9 THEN LET c_minutes = f_minutes; ELSE LET c_minutes = "0" || f_minutes; END IF LET f_hours = (thehourminute - f_minutes ) / 100; IF f_hours > 9 THEN LET c_hours = f_hours; ELSE LET c_hours = "0"|| f_hours; END IF LET f_fractionsecs=mod(thesecconds,100); IF f_fractionsecs > 9 THEN LET c_fractionsecs =f_fractionsecs ; ELSE LET c_fractionsecs = "0" || f_fractionsecs ; END IF LET f_secs = (thesecconds - f_fractionsecs) /100; IF f_secs > 9 THEN LET c_secs = f_secs; ELSE LET c_secs = "0"|| f_secs; END IF LET retvalue = f_datepiece || " "|| c_hours||":"||c_minutes||":"||c_secs||"."||c_fract ionsecs; RETURN retvalue; END FUNCTION; create table tx ( a date, b smallint, c smallint); insert into tx values (today,1301,1501); insert into tx values (today,101,501); select * from tx where convittodatetime (a,b,c) > current ; -- gives one row... assume you run this in the morning... select * from tx where convittodatetime(a,b,c) < current ; -- gives one row... assume you run this in the morning... You could also use the spl above to build an index ... Oh and if there is a mistake in the data it does return "1970-01-01 00:00:00.0"; Superboer. On 13 mrt, 05:13, Jonathan Leffler <jleffler.i... (AT) gmail (DOT) com> wrote: On Fri, Mar 12, 2010 at 14:43, J. Hart <unleashedman... (AT) gmail (DOT) com> wrote: We have a vendor product and in their informix database, they have their date, time and seconds separated in 3 different columns. item_date (date field) item_time (smallint field) item_seconds (smallint field) Sample data: 03/12/10 41 1303 (Ie... 03/12/10 00:41:13.03) 03/12/10 330 4900 (Ie... 03/12/10 03:30:49.00) 03/12/10 710 1001 (Ie... 03/12/10 07:10:10.01) 03/12/10 1336 3300 (Ie... 03/12/10 13:36:33.00) My question is... I want to be able to pass in a Date, Time and Seconds and only get records after that specific time. In a normal database, I would just say, SELECT * FROM MYTABLE WHERE EventDateTime = '03/12/2010 13:01.000', but I don't know how to do it with these three columns. And, you can't just do WHERE item_date >= '03/12/10' and item_time >= '1244' and item_seconds >= '1100' A guy I work with said I should try to convert the tree columns to a julian date and then compare the julian dates. Ugh. Talk about deliberately making everyone's life hard! Assuming the parameters are value_date, value_time and value_seconds, the basic structure of the condition is: WHERE ((value_date < item_date) OR (value_date = item_date AND value_time < item_time) OR (value_date = item_date AND value_time = item_time AND value_seconds < item_seconds)) -- Jonathan Leffler #include <disclaimer.h Email: jleff... (AT) earthlink (DOT) net, jleff... (AT) us (DOT) ibm.com Guardian of DBD::Informix v2008.0513 --http://dbi.perl.org/ "Blessed are we who can laugh at ourselves, for we shall never cease to be amused." NB: Please do not use this email for correspondence. I don't necessarily read it every week, even. _______________________________________________ Informix-list mailing list Informix-list (AT) iiug (DOT) org http://www.iiug.org/mailman/listinfo/informix-list |
#5
| |||
| |||
|
|
We have a vendor product and in their informix database, they have their date, time and seconds separated in 3 different columns. item_date (date field) item_time (smallint field) item_seconds (smallint field) Sample data: 03/12/10 * * * *41 * * *1303 * *(Ie... 03/12/10 00:41:13.03) 03/12/10 * * * *330 * * 4900 * *(Ie... 03/12/10 03:30:49.00) 03/12/10 * * * *710 * * 1001 * *(Ie... 03/12/10 07:10:10.01) 03/12/10 * * * *1336 * *3300 * *(Ie... 03/12/10 13:36:33.00) My question is... I want to be able to pass in a Date, Time and Seconds and only get records after that specific time. *In a normal database, I would just say, SELECT * FROM MYTABLE WHERE EventDateTime>='03/12/2010 13:01.000', but I don't know how to do it with these three columns. *And, you can't just do WHERE item_date >= '03/12/10' and *item_time >= '1244' and item_seconds >= '1100' A guy I work with said I should try to convert the tree columns to a julian date and then compare the julian dates. Thanks for any help you can provide. |
#6
| |||
| |||
|
|
On Mar 12, 3:43 pm, "J. Hart"<unleashedman... (AT) gmail (DOT) com> wrote: We have a vendor product and in their informix database, they have their date, time and seconds separated in 3 different columns. item_date (date field) item_time (smallint field) item_seconds (smallint field) Sample data: 03/12/10 41 1303 (Ie... 03/12/10 00:41:13.03) 03/12/10 330 4900 (Ie... 03/12/10 03:30:49.00) 03/12/10 710 1001 (Ie... 03/12/10 07:10:10.01) 03/12/10 1336 3300 (Ie... 03/12/10 13:36:33.00) My question is... I want to be able to pass in a Date, Time and Seconds and only get records after that specific time. In a normal database, I would just say, SELECT * FROM MYTABLE WHERE EventDateTime>= '03/12/2010 13:01.000', but I don't know how to do it with these three columns. And, you can't just do WHERE item_date>= '03/12/10' and item_time>= '1244' and item_seconds>= '1100' A guy I work with said I should try to convert the tree columns to a julian date and then compare the julian dates. Thanks for any help you can provide. Oh, I forgot to add in that the informix database is a read only DR server. So, we are not able to alter the table structure, create stored procedures/functions or temp tables... It's a pain in the neck dealing with the vendor and informix. I wish there was an easy solution for replicating informix to MS SQL. |
#7
| |||
| |||
|
|
Oh, I forgot to add in that the informix database is a read only DR server. So, we are not able to alter the table structure, create stored procedures/functions or temp tables... It's a pain in the neck dealing with the vendor and informix. *I wish there was an easy solution for replicating informix to MS SQL. James |
#8
| |||
| |||
|
| On Fri, Mar 12, 2010 at 14:43, J. Hart <unleashedmaniac (AT) gmail (DOT) com mailto:unleashedmaniac (AT) gmail (DOT) com>> wrote: We have a vendor product and in their informix database, they have their date, time and seconds separated in 3 different columns. item_date (date field) item_time (smallint field) item_seconds (smallint field) Sample data: 03/12/10 41 1303 (Ie... 03/12/10 00:41:13.03) 03/12/10 330 4900 (Ie... 03/12/10 03:30:49.00) 03/12/10 710 1001 (Ie... 03/12/10 07:10:10.01) 03/12/10 1336 3300 (Ie... 03/12/10 13:36:33.00) My question is... I want to be able to pass in a Date, Time and Seconds and only get records after that specific time. In a normal database, I would just say, SELECT * FROM MYTABLE WHERE EventDateTime = '03/12/2010 13:01.000', but I don't know how to do it with these three columns. And, you can't just do WHERE item_date >= '03/12/10' and item_time >= '1244' and item_seconds >= '1100' A guy I work with said I should try to convert the tree columns to a julian date and then compare the julian dates. Ugh. Talk about deliberately making everyone's life hard! Assuming the parameters are value_date, value_time and value_seconds, the basic structure of the condition is: WHERE ((value_date < item_date) OR (value_date = item_date AND value_time < item_time) OR (value_date = item_date AND value_time = item_time AND value_seconds < item_seconds)) |
#9
| |||
| |||
|
|
On 15/03/2010 15:11, J. Hart wrote: On Mar 12, 3:43 pm, "J. Hart"<unleashedman... (AT) gmail (DOT) com> *wrote: We have a vendor product and in their informix database, they have their date, time and seconds separated in 3 different columns. item_date (date field) item_time (smallint field) item_seconds (smallint field) Sample data: 03/12/10 * * * *41 * * *1303 * *(Ie... 03/12/10 00:41:13.03) 03/12/10 * * * *330 * * 4900 * *(Ie... 03/12/10 03:30:49.00) 03/12/10 * * * *710 * * 1001 * *(Ie... 03/12/10 07:10:10.01) 03/12/10 * * * *1336 * *3300 * *(Ie... 03/12/10 13:36:33.00) My question is... I want to be able to pass in a Date, Time and Seconds and only get records after that specific time. *In a normal database, I would just say, SELECT * FROM MYTABLE WHERE EventDateTime>= '03/12/2010 13:01.000', but I don't know how to do it with these three columns. *And, you can't just do WHERE item_date>= '03/12/10' and *item_time>= '1244' and item_seconds>= '1100' A guy I work with said I should try to convert the tree columns to a julian date and then compare the julian dates. Thanks for any help you can provide. Oh, I forgot to add in that the informix database is a read only DR server. So, we are not able to alter the table structure, create stored procedures/functions or temp tables... It's a pain in the neck dealing with the vendor and informix. *I wish there was an easy solution for replicating informix to MS SQL. The problem is your database not your DBMS. I expect Jonathan Leffler's solution would apply to that database structure regardless of whether it was implemented using IBM Informix IDS or Microsoft SQL server. Are you having some problem applying Jonathan's solution? -- RGB- Hide quoted text - - Show quoted text - |
#10
| |||
| |||
|
|
Oh, I forgot to add in that the informix database is a read only DR server. So, we are not able to alter the table structure, create stored procedures/functions or temp tables... It's a pain in the neck dealing with the vendor and informix. *I wish there was an easy solution for replicating informix to MS SQL. James As somewhat of a side note, if you have a temporary dbspace that was created with the -t option, then even on a read only server of a HDR pair, you can still create/use temporary tables. *You just need to ensure they are built with the "with no log" option and they should work fine. Jacques Renaut IBM Informix Advanced Support APD Team |
![]() |
| Thread Tools | |
| Display Modes | |
| |