Solved

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

Posted on 2004-08-30
5
13,265 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
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…

707 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

13 Experts available now in Live!

Get 1:1 Help Now