Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Updating datetime fields
Message
De
18/10/2001 05:36:57
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
18/10/2001 04:20:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00570098
Message ID:
00570109
Vues:
12
>Hi Sergey,
>
>I now trying to insert date time values with date time fields, I just can't make it work properly. Can you help me with this one. Thanks..
>
>cEdtdt = ["] + Datetime() + ["]
>cRegdt = ["] + Datetime() + ["]
>
>cSQL = [INSERT INTO bbfs!dispatchinv(] +;
>>>>>>>>[dcno,] +;
>>>>>>>>[dispatchno,]+;
>>>>>>>>[edtdt,] +;
>>>>>>>>[regdt,] +;
>[values( ] + Alltrim(Str(cDcno)) + [,] +; >>>>>>>>>>>+ Alltrim(Str(cDispatchno)) + [,] +;
>>>>>>>>>>>>cEdtdt + [,] +; >>>>>>>>>>>cRegdt + [)]

Mike,
cEdtdt = ["] + Datetime() + ["]

Would error. You're tring to concatanate a datetime value with char values. Is it needed for SQL server with SQL pass through ? If so SQL pass through and remotevies use ODBC connection and datetime values need to be in ODBC canonical format ('YYYY/MM/DD hh:mm:ss').
store transform(ttoc(datetime()-100000,1),'@R 9999/99/99 99:99:99') ;
 to cEdtdt,cRegdt

cSQL = [INSERT INTO dispatchinv ] +;
  [ (dcno,dispatchno,edtdt,regdt)] +;	
  [ values( ] + Str(cDcno) + [,] +;
  Str(cDispatchno)+ [,] + cEdtdt + [','] + cRegdt + [')]
However for datetime() you could directly use SQL server's GetDate() function :
cSQL = [INSERT INTO dispatchinv ] +;
  [ (dcno,dispatchno,edtdt,regdt)] +;	
  [ values( ] + Str(cDcno) + [,] +;
  Str(cDispatchno)+ [, GetDate(), GetDate() )]
OTOH seeing 'bbfs!dispatchinv' I guess this is not SQL server but VFP. Then corresponding syntax of above would be :
store '{'+;
 transform(ttoc(datetime()-100000,1),'@R ^9999/99/99 99:99:99') + '}' ;
 to cEdtdt,cRegdt

cSQL = [INSERT INTO bbfs!dispatchinv ] +;
  [ (dcno,dispatchno,edtdt,regdt)] +;	
  [ values( ] + Str(cDcno) + [,] +;
  Str(cDispatchno)+ [,]+;
  cEdtdt+ [,] + cRegdt + [)]
Directly using datetime() :
cSQL = [INSERT INTO dispatchinv ] +;
  [ (dcno,dispatchno,edtdt,regdt)] +;	
  [ values( ] + Str(cDcno) + [,] +;
  Str(cDispatchno)+ [, Datetime(), DateTime() )]
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform