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 6946789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:36:37+00:00 2026-05-27T13:36:37+00:00

I am reading a sqlite file in which datetime column data are saved as

  • 0

I am reading a sqlite file in which datetime column data are saved as integer values (INTEGER NO NULL)

DateTime dt=reader.GetDateTime(nColDateTime);

But it emits an error saying that the return value is not in correct format.
I try out all other available methods in Datetime class and find only

DateTime dt=DateTime.FromBinary(reader.GetInt64(nColDateTime));

works (as others return exceptions).
But the formatted date (as dt.ToShortDateTime()) is incorrect (ie 0042/11/20) I have no idea what this is.
I then try this

long d=DateTime.Now.Ticks-reader.GetInt64(nColDateTime);
DateTime dt=new DateTime(d);

It gives me 1970/05/18

Could you help me to get the correct datetime ?

  • 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-05-27T13:36:38+00:00Added an answer on May 27, 2026 at 1:36 pm

    Your dates are stored in the Unix epoch format.

    You probably just want to use:

    private static readonly DateTime epoch = new DateTime(1970, 1, 1);
    
    ...
    
    var myDate = epoch + TimeSpan.FromTicks(reader.GetInt64(nColDateTime));
    

    For example, when I look at your example above “1970/05/18”, I can assume that your date is approximately 5 months, 18 days earlier than today.

    Here is how I would retreieve the original value:

    (DateTime.Today - new DateTime(1970, 5, 18)).Ticks
    

    Which returns:

    13119840000000000
    

    Plugging that into my formula:

    new DateTime(1970, 1, 1) + TimeSpan.FromTicks(13119840000000000)
    

    This returns:

    2011/07/30
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to import a .sqlite file into Core Data, I searched on the
I have a SQLite database that is created by reading some data in PDF
I currently have a .csv file with several unlabeled columns of data, which to
I have a text file with 50k+- lines and each line contains data which
Hi i have a file called test.sqlite. How do i go about reading all
Possible Duplicate: Reading and writing images to an SQLite DB for iPhone use How
In Qt I need to send a sqlite file (binary file) up to a
I've been reading through this tutorial for using a SQLite database within an iPhone
I'm programming a simple customer-information management software now with SQLite. One exe file, one
I was reading the SQLite FAQ , and came upon this passage: Threads are

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.