简体   繁体   中英

iOS - Sqlite store as `DATE` or `day`, `month`, `year`?

I want to generate monthly & yearly report eventually.

Let say I have a table transaction which consists of (price, date, ...) , I want to generate a report which group by month .

Should I store the date as 3 separate fields day , month , and year ? Or I can store it as date with Date data type?

If date , how is the query look like and how to implement it in iOS?

NOTE: I'm new to iOS

Thanks in advance.

In databases, you should always want to store dates as dates, not as their component fields.

SQLite provides various functions for manipulating and ordering dates, so you can use them.

Getting the month out of a date is quite easy.

Use the date .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM