Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Error Update TimeStamp Field

Posted on 2008-06-12
7
Medium Priority
?
489 Views
Last Modified: 2013-11-23
Hi all,

i get this error when trying to execute query - SQL Server Error: conversion error from string "6/13/2008 1:03:12 AM".

This is my code

d := DateTimeToStr(Now);

Format('EXECUTE PROCEDURE SP_UPDATESERIALNO(%s, %s)',
        [QuotedStr(SerialNo),  QuotedStr(d)]);

and the query will look like this.

EXECUTE PROCEDURE SP_UPDATESERIALNO('12345', '6/13/2008 1:03:12 AM')

What is wrong? How do i convert date from TDateTime to the date that Database will understand.
field type in database is TimeStamp

Thanks
0
Comment
Question by:reynaldio
[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
  • 4
  • 3
7 Comments
 
LVL 14

Expert Comment

by:SteveBay
ID: 21772230
0
 
LVL 2

Author Comment

by:reynaldio
ID: 21772608
Thanks stevevbay for your quick response.

I see the link you gave me. but what is I have TDateTime and i want to update field that is TimeStamp.

i tried this but i get invalid argument error


var
  v: Variant;
  tstamp: TSQLTimeStamp;
  d: String;
begin
  tstamp := datetimetosqltimestamp(now);
  v := VarSQLTimeStampCreate(TSQLTimeStamp(tstamp));
  d := TimeStampToStr(v);
  MessageDlg(d, mtConfirmation, [mbOK], 0);
end;
0
 
LVL 14

Expert Comment

by:SteveBay
ID: 21772708
You cannot update a TimeStamp field in MSSQL. It's an automatic field.
Please see:
http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_23314218.html
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Author Comment

by:reynaldio
ID: 21772805
hi,

i dont use MSSQL, i use firebird. sorry i didnt mention it earlier.
i can update my timestamp field if i update it from dataset.

something like this.

dsMYDATEFIELD.AsDateTime := Date;
ds.ApplyUpdates(0);

but if i want to update with execsql like i mention ealier, i got that error.
any other suggestion?
0
 
LVL 14

Accepted Solution

by:
SteveBay earned 2000 total points
ID: 21772862
Oh. That does make a difference. I should have remembered that from the the last issue you posted.
I am afraid that I can't help with Firebird issues - I never touch the stuff ;-)
0
 
LVL 2

Author Comment

by:reynaldio
ID: 21772944
Hi,

i finally got it solved. all i need to do is give the right formatting
d := FormatDateTime('yyyy-MM-dd hh:mm:ss', Now);

i'll give you the points anyway for your efforts.

thanks alot steve bay
0
 
LVL 2

Author Closing Comment

by:reynaldio
ID: 31466671
thanks :)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

636 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