Reputation: 25
I am using two databases one as a main database and the second as a branch. i add a table to save a timestamp for every database. what i need is to get data from database to sync it in the branches according to the last syc timestamp in every branch. i get the last timestamp from the databases as a string. what i need is to send this timestamp to the main database (web server). how can i convert this string to timestamp in c# or if there is another way like to add this timestamp as varchar parameter and convert it in the stored procedure.
Thanks in advance.
Upvotes: 0
Views: 341
Reputation: 25
I found the solution is by getting the timestamp from database converted to varchar using master.sys.fn_varbintohexstr(cast(timeStampVariable as varbinary(8))) then send it to the other database as string where i need to store it as a string in a parameter table... thanks for all who try to help.
Upvotes: 0
Reputation: 13409
DateTime.Parse
or DateTime.TryParse
methods will let you convert string
to datetime
. The other way around is simply a .ToString
on the DateTime
, you can also provide formats if you want.
Upvotes: 1