Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-08-30
5
Medium Priority
?
13,869 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
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…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

885 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