Solved

SQL0180N  The syntax of the string representation of a datetime value is incorrect.  SQLSTATE=22007

Posted on 2004-08-30
5
13,342 Views
Last Modified: 2011-08-18
Hello everyone.
  I'm a newbie here...so go easy on me.  I have the following code in a .cmd file ( sdv.cmd ).  I run it from a command prompt like this c:\sdv.cmd >h:\projects\sdv.txt.  It runs fine and it does what i want it to except that I want it to prompt for a date so I don't have to hard code the SQL date to a differnet date each day.  

How do a set a arg for the date and have it prompt the user to enter a date.

We are using a DB2 database.  ( sorry, that's all I know )


/***************************************************************************************
* THIS WILL EXTRACT DATA                                                                                                                                  *
*                                                                                                                                                                          *
***************************************************************************************/

'Dbmucmd mydatabase "select',
      'c.cust_rt_nbr,',
        'a.ord_appv_deliv_dt,',
        'a.ord_doc_nbr,',
        'd.hhc_descp_txt,',
        'd.selling_code,',
        'b.ord_orig_item_qty,',
        'b.ord_curr_item_qty,',
        'b.ship_recv_item_qty,',
        'b.ord_item_um_code,',
        'd.sdv_amt,',
        'e.unit_per_case_qty,',
        'e.cdy_per_case_qty,',
        'a.acctg_dest_loc_nm',
 'from oms.ord_ship_hdr a,',
        'oms.ord_ship_ln b,',
        'oms.ord_cust_rt c,',
        'slp.product_code_attr d,',
        'iim.sku e',
 'where a.ord_cancl_flg=''0'' and',
        'a.ord_delte_flg=''0'' and',
        'a.purge_flg=''0'' and',
        'c.rt_type=''01'' and',
        'a.ord_appv_deliv_dt=''2004-08-30'' and', <<<<<<<<<<<<<<<<< (This date )
        'a.ord_doc_nbr=b.ord_doc_nbr and',
        'a.ord_doc_nbr=c.ord_doc_nbr and',
        'b.prod_nbr=e.prod_nbr and',
        'b.case_seq_nbr=e.case_seq_nbr and',
        'b.prod_nbr=d.prod_code and',
        'd.PROD_C_ATTR_END_DT>=a.ORD_APPV_DELIV_DT ',
        ' AND A.ORD_TYPE_CODE<>''66'' ',
        ' AND A.ORD_TYPE_CODE<>''65'' ',
   'order by c.cust_rt_nbr,',
           'a.ord_appv_deliv_dt,',
           'a.ord_doc_nbr,',
           'd.selling_code"'

*****************************************************************************************

Thanks a million
     
 
0
Comment
Question by:awehme
  • 3
  • 2
5 Comments
 
LVL 2

Author Comment

by:awehme
ID: 11936344
Sorry, forgot the other part.  I have stole this code from another program we have and have placed in front of the sql above, but when I do that I get the following error

SQL0180N  The syntax of the string representation of a datetime value is incorrect.  SQLSTATE=22007

I did replace the date ( "2004-08-30") with DelDate


DelDate = ""

PARSE UPPER ARG delDate

do while (DelDate = "")
   say ""
   say "Missing the Del Date.  Please re-enter."
   say ""
   say "    Format: YYYY-MM-DD"
   say ""
   PARSE UPPER PULL DelDate
   Deldate = DelDate
   DelDate = left(deldate,4)||'-'||right(deldate,5)
end

0
 
LVL 4

Expert Comment

by:chanito
ID: 11937906
The program looks fine, are you using quotes to enter the date?
0
 
LVL 2

Author Comment

by:awehme
ID: 11938167
no, should I .........single or double quotes ( ' or '' or " )

Thanks
0
 
LVL 4

Accepted Solution

by:
chanito earned 500 total points
ID: 11942260
I don't think you should use quotes but can't hurt to try it.  I can't tell for sure from your examples the synthax you should use but, the line where you replace the date should be something like:

'a.ord_appv_deliv_dt='||DelDate||' and',

Also, it seems it's case senstivite, so even though the parameter parsing part is confusing I'd try it with delDate and deldate.
0
 
LVL 2

Author Comment

by:awehme
ID: 11959553
Thanks canito,  putting the || around the arg worked.  Thanks
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Database tuning – How to start and what to tune. This question is frequently asked by many people, both online and offline. There is no hard and fast rule-of-thumb for performance tuning, however, before beginning the tuning process one should a…
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now