Subject Re: DATE VALUE in SQL
From WJS <warra@nowhere.com>
Date Fri, 16 Nov 2018 05:50:34 +0200
Newsgroups dbase.getting-started

On 2018-11-15 11:19 AM, Mustansir Ghor wrote:
> Dear All
>
> mdate1=dtoc(date())
> mregno='123456'
> mrate=123456
> cmd = 'insert into dissales (sdate,item,reg,rate) values("'+mdate1+'","9B100","'+mregno+'",'+mrate+')'
> &cmd.
>
> In the above statement it gives error because of date format. I am using date as british format.
>
> Any suggestion how to go about correcting the statement.
>
> Regards
> Mustansir
>
My Suggestion:
mDate1 = date() //this is a real date !
mRegno = '123456'
mRate = 123456
mItem = "9B100"

(this is one line. Watch wrap !)
insert into disSales (sdate,item,reg,rate) values( :mDate1, :mItem,
:mRegNo, :mRate)

My experience is if you put the date in a variable, there is no need to
convert it to a string or american date format, no matter what your own
date setting is.
Converting is only necessary if you use literal values in the sql command.
Note also the colon (:) as prefix for the variables.

Wian