This is done using the 'NNN years' modifier with the datetime function as follows: sqlite> SELECT datetime('','+2 years') You can use the datetime function to manipulate a date/time value and add or subtract years to it. Result: ' 15:21:07' (formatted as YYYY-MM-DD HH:MM:SS) Adding/Subtracting Years Example You could retrieve the current date and time in SQLite using the "now" timestring with the datetime function as follows: sqlite> SELECT datetime('now') Let's look at some SQLite datetime function examples and explore how to use the datetime function in SQLite. Used with the DDDDDDDDDD timestring to interpret the date as UNIX Time (ie: number of seconds since )Īdjusts date to localtime, assuming the timestring was expressed in UTCĪdjusts date to utc, assuming the timestring was expressed in localtime (0=Sunday, 1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday, 6=Saturday) Moves the date forward to the next date where weekday number is N Shifting the date back to the start of the day Shifting the date back to the start of the month Shifting the date back to the start of the year Number of seconds (and fractional seconds) added/subtracted to the date Number of seconds added/subtracted to the date Number of minutes added/subtracted to the date Number of hours added/subtracted to the date Number of days added/subtracted to the date Number of months added/subtracted to the date Number of years added/subtracted to the date They can be one or more of the following: Each modifier is applied in order and are cumulative. These are modifiers that are applied to the timestring. Now is a literal used to return the current date.ĭate value formatted as 'YYYY-MM-DD HH:MM'ĭate value formatted as 'YYYY-MM-DD HH:MM:SS'ĭate value formatted as 'YYYY-MM-DD HH:MM:SS.SSS'ĭate value formatted as 'YYYY-MM-DD THH:MM' where T is a literal character separating the date and time portionsĭate value formatted as 'YYYY-MM-DD THH:MM:SS' where T is a literal character separating the date and time portionsĭate value formatted as 'YYYY-MM-DD THH:MM:SS.SSS' where T is a literal character separating the date and time portions
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |