Task: display information about a product that has been sold less than a year ago. Structure fields: seller, product name, price, date of sale. How to store the date?

Closed due to the fact that the issue is too general for the participants jfs , user194374, Vlad , Vlad from Moscow , Harry 6 Feb '17 at 12:32 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    Как правильно хранить дату? - in the form of a timestamp . The time stamp is resistant to transitions between summer / winter time and time zones. - ߊߚߤߘ
  • timestamp are different, unix-timestamp or YYYYMMDDHHIISS , for example. With any of these incidents are possible, you always need to understand how to cook. - vp_arth
  • According to the condition, it is not stated in what form the date should be stored: date.month.year or day-month-year. Is time.h suitable for this purpose? If so, how to work with it correctly? Just a little confused ... - Pavel
  • one
    @Pavel, I would like to clarify: where exactly the date is stored and what does C. have to do with. At postgres, for example, I would store it as a 'timestamp with / without time zone` (this is a separate type in the database). Samples of the level "a year ago" are made elementary, but how to work with this code from a code is another question. Also, by the way, very simple ... - PinkTux
  • one
    "How to store the date?" depends on the task (which database is used (sqlite, postgres), what date operations you want to perform, how much accuracy is the clock, time zones, etc.) in your case. - jfs

1 answer 1

How convenient for processing.
I would consider both options as a number YYYYMMDD or a Julian day .