Advertisement

06.06.2008 at 09:10AM PDT, ID: 23464225
[x]
Attachment Details

Informix dates are driving me crazy!

Asked by Clothahump in Informix Database

I have two queries that I am trying to run.  The user enters a startdate, a stopdate and a program.  I then dynamically build the SQL statements are run them.  On both queries, the field that I am using for the date range is defined as datetime.  Query 1 works, query 2 blows out with a "Non-numeric character in datetime or interval" error.

What's the secret to querying Informix date fields?  I haven't got much hair left, as I'm pulling it out on a daily basis?

Query 1:
SELECT MVOD.ord_area AS Program, V.med_rec_num AS PatientID, MVOD.patient_name, V.visit_id, V.admit_date, V.weight_kg, V.height_cm, MVOD.ord_room_bed, V.attending_doctor, P.birthdate, P.sex, MVOD.ord_order_num, MVOD.dos_generic_name, MVOD.dos_brand_name, MVOD.orh_verified, MVOD.ord_time_sch, MVOD.dos_admin_hour, MVOD.dos_dose, MVOD.dos_route, MVOD.dos_frequency, MVOD.dos_drug_name, MVOD.ord_time_act, MVOD.orh_admin_dose, MVOD.orh_disp_size, MVOD.orh_disp_unit, MVOD.ord_notes, MVOD.orh_start_date, MVOD.orh_stop_date, MVOD.ord_admin_by, A.description AS Allergies, C.description AS diagnosis, MVOD.dos_admin_instr, MVOD.dos_instruction, '05/25/2008' AS StartDate, '05/31/2008' AS EndDate FROM mar_vw_ord_dtl AS MVOD INNER JOIN visit AS V ON MVOD.visit_id = V.visit_id INNER JOIN patient AS P ON V.med_rec_num = P.med_rec_num LEFT JOIN allergy AS A ON P.med_rec_num = A.med_rec_num LEFT JOIN Conditions AS C ON V.visit_id = C.visit_id WHERE MVOD.ord_area ='COM' AND V.med_rec_num > '00009999' AND (MVOD.ord_time_sch Between '2008-05-25 00:00' And '2008-05-31 23:59') ORDER BY V.med_rec_num, MVOD.ord_order_num, MVOD.ord_time_act;



Query 2:
SELECT V.med_rec_num AS PatientID, MDAN.dan_entered_on AS NotesDate, MDAN.dan_entered_by AS EnteredBy, MDAN.dan_addl_comment AS Notes, MVOD.dos_brand_name, MVOD.ord_time_act, MVOD.ord_area AS Program FROM (mar_dose_addl_note MDAN INNER JOIN mar_vw_ord_dtl MVOD ON MDAN.dan_ord_id = MVOD.ord_id) INNER JOIN visit V ON MVOD.visit_id = V.visit_id where (MDAN.dan_entered_on between '2008-05-25 00:00' and '2008-05-31 23:59') and MVOD.ord_area='COM'
Start Free Trial
 
Loading Advertisement...
 
[+][-]06.07.2008 at 01:12AM PDT, ID: 21734676

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Informix Database
Sign Up Now!
Solution Provided By: gheist
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.07.2008 at 04:25AM PDT, ID: 21735059

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.07.2008 at 01:01PM PDT, ID: 21736636

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906