Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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,770 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

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 blog post, we’ll look at how using thread_statistics can cause high memory usage.
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

671 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