Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7736443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:43:57+00:00 2026-06-01T07:43:57+00:00

What is the formatting difference between: DateTime datetimenow = DateTime.Now.ToLocalTime(); and long ticks =

  • 0

What is the formatting difference between:

DateTime datetimenow = DateTime.Now.ToLocalTime();

and

long ticks = 634687637580000000;
DateTime createdTimestamp = new DateTime(ticks).ToLocalTime();

Which causes SQL Server CE to throw error

There was an error in a part of the date format. [ Expression (if
known) = ]

I am attempting to insert two timestamps into a SQL Server CE database. The current date time and a date time from the past. The current date and time (now) can be inserted into both target fields in the table, however when I use the createdTimestamp the error above is thrown.

The format when I review the locals in debug are exactly the same between the two.

The target fields are both of datetime data type.

Why might this error be thrown?

Edit:

I’ve just found it appears to only affect timestamps in the past. Now and future timestamps work fine.

Edit: adding code for SQL insertion.

Query is built dynamically by my own SQL Server CE class.

{INSERT timeline (TweetID,Author,TimestampOfTweet,TimestampOfCollected,TweetText) VALUES ('185941815562739713','twitterapi','15/12/2011 13:52:39','01/04/2012 15:58:58','TweetDeck access - Update : This issue has been resolved. http://t.co/2yub0tYL')}

Execution Code:

//Take built statement and apply to command text
cmd.CommandText = buildSqlStatement.ToString();

//execute insert
try
{
   cmd.Connection = sqlConn;
   sqlConn.Open();
   int rows = cmd.ExecuteNonQuery();
   string results = Convert.ToString(rows);
   return results;
}
catch(Exception ex)
{
   return ex.Message;
}
finally
{
   sqlConn.Close();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:43:59+00:00Added an answer on June 1, 2026 at 7:43 am

    Never include values directly in your SQL – always use parameterized SQL instead.

    Benefits:

    • Clean separation of “code” (the SQL) from data (the values)
    • Protection against SQL injection attacks
    • Avoids error-prone conversions such as in this question.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody tell me the difference between these two ways of formatting numbers using
I have some conditional formatting styles. I don't want to keep creating new rules
What is the difference between UIAccelerometer and CLLocationManager? Both give me x, y and
does it matter which quotes i use when i do conditional formatting? for example
Is the difference between integer multiply(temporarily forgetting about division) still in favor of shifting
Is there a perceptible difference between using String.format and String concatenation in Java? I
I'm using pyodbc to query to an SQL Server database import datetime import pyodbc
I am trying to convert DateTime object to string using formatting but due to
Can someone shed some light on what the difference is between these two types
Excel has a Conditional Formatting... option under the Format menu that allows you to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.