Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2007
    Posts
    31

    Unanswered: Query Syntax Problem with Date Range

    Hello,
    In the following query, I am trying to pull records within a specific date range. The query is as follows:

    SELECT FM_RK_TRN_DTE, FM_TR_TRN_TIME, FMDL_BILLING_TYPE,
    FMDL_PRODUCT_GROUP, FM_RK_CNTL_NBR, FM_CUST_ACCOUNT_CD,

    FM_TR_SC_INVC_NBR, FM_ACCOUNT_NAME, FM_CUST_CUST_ID,
    FM_DT_CMCHK_CRDNBR, FM_SC_SRVC_CNTR_CD, FM_SC_NAME,

    FM_SC_CHAIN_CD, FM_TR_TRACTR_GAL, FM_TR_TRACTR_PPG,
    FM_TR_TRACTR_COST, FM_TR_TRLR_GAL, FM_TR_TRLR_PPG,

    FM_TR_TRLR_COST, FM_TR_OTHER_GAL, FM_TR_OTHER_PPG,
    FM_TR_OTHER_COST, FM_TF_OTHER_FUEL, FM_TF_CASH, FM_TF_OIL,
    FM_TF_PROD_1, FM_TF_PROD_2, FM_TF_PROD_3,
    FM_TR_OIL_COST, FM_TR_PROD_CD_1, FM_TR_PROD_AMT_1, FM_TR_PROD_CD_2,

    FM_TR_PROD_AMT_2, FM_TR_PROD_CD_3, FM_TR_PROD_AMT_3,
    FM_RD_FUEL_RT, FM_RD_CASH_ADVC_RT, FM_RD_SC_TRN_FEE,

    FM_BR_SRVC_CNTRFEE, FM_SC_RD_SC_SLT_DS, FMDL_COMDATA_FEES,
    FMDL_DISCOUNT_AMT, FM_CDN_CMPLT_TY, FM_DT_EXP_CASH_FG,

    FM_BR_TRN_FG, FM_PAY_AT_LOAD_FG, FM_TEXACO_CRXTN_FL,
    FM_CO_CR_FL, FMDL_REBATE_AMT, FMDL_FLEET_CRD_XTN,

    FMDL_FLEET_MCC, FM_C_TXC_COBRND_FL, FM_SC_CR_FL,
    FM_SC_TEXACO_FL, P105S1_FILE_TY, P105S2_FILE_R_DT, P105S3_PROC_ID,

    P105S4_FILE_SEQ_NO, P501S3_OCC_IND,
    P501S4_MSG_NO, FM_SC_CORPORT_CD, FM_SC_RD_FUEL_RT, FM_BC_RD_CSHADVCRT,

    FM_PRFD_LVL_FG, FM_RD_COMP_HND_CHG,
    FM_CUST_CORPORT_CD, FM_IN_NTW_FG, FM_SC_STATE, FMdl_TOTAL_GALLONS, FM_BC_RD_FUEL_RT, FM_SC_RD_CSHADVCRT, FM_CRCY_FG, FM_TR_CASH_ADVCAMT, FM_BILLING_FG, FM_TF_TRACTR_FUEL, FM_TF_TRLR_FUEL, FM_CUST_NAME, FM_BC_RD_SC_SLT_DS, FM_CSTPLS_USED, FM_SLCT_FCS_DISC, FM_CUST_ALLIANC_FG
    FROM
    CBDBOW.FUEL_MGLOG
    WHERE FM_RK_TRN_DTE >= '2008-04-28' AND FM_RK_TRN_DTE =< '2008-05-30' AND fm_cust_corport_cd = 'pc222'

    ***************
    FM_RK_TRN_DTE is DATE datatype. The DB2 version is 9, the OS is AIX 5.3.0. I am running this through an ODBC connection, and I get an error that the query was unable to process the data. I've tried different date ranges and I get the same error. I've tried using BETWEEN/AND for the data range, but no luck.

    What am I doing wrong?

    Thank you for your help.

    cdun2

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    WHERE FM_RK_TRN_DTE between '2008-04-28' AND '2008-05-30' AND fm_cust_corport_cd = 'pc222'

    or

    WHERE FM_RK_TRN_DTE >= '2008-04-28' AND FM_RK_TRN_DTE <= '2008-05-30' AND fm_cust_corport_cd = 'pc222'

    Either one should work, the first one is always preferable.

    Andy

  3. #3
    Join Date
    Apr 2007
    Posts
    31
    I used 'between' and 'and', and used this last in the WHERE clause. I was trying to do this through an ODBC connection. It worked out.

    Thank you for your help.

    cdun2

  4. #4
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Deleted by Tonkuma.
    Last edited by tonkuma; 06-27-08 at 23:00.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •