SQLite DateTime Modifiers

The following table shows you the SQLite datetime modifiers that you can use to manipulate date and time values within the datetime functions:

ModifierExplanation
±NNN daysAdds or subtracts the specified number of days to/from a date or datetime value.
±NNN hoursAdds or subtracts the specified number of hours to/from a datetime value.
±NNN minutesAdds or subtracts the specified number of minutes to/from a datetime value.
±NNN secondsAdds or subtracts the specified number of seconds to/from a datetime value.
±NNN monthsAdds or subtracts the specified number of months to/from a date or datetime value.
±NNN yearsAdds or subtracts the specified number of years to/from a date or datetime value.
±HH:MMAdds or subtracts the specified offset in hours and minutes to/from a datetime value.
±HH:MM:SSAdds or subtracts the specified offset in hours, minutes, and seconds to/from a datetime value.
±HH:MM:SS.SSSAdds or subtracts the specified offset in hours, minutes, seconds, and milliseconds to/from a datetime value.
±YYYY-MM-DDAdds or subtracts the specified date to/from a date or datetime value.
±YYYY-MM-DD HH:MMAdds or subtracts the specified date and time to/from a datetime value.
±YYYY-MM-DD HH:MM:SSAdds or subtracts the specified date and time to/from a datetime value.
±YYYY-MM-DD HH:MM:SS.SSSAdds or subtracts the specified date and time to/from a datetime value.
start of monthReturns the first day of the month for a given date or datetime value.
start of yearReturns the first day of the year for a given date or datetime value.
start of dayReturns the start of the day (midnight) for a given date or datetime value.
weekday NReturns the date of the first weekday (Sunday as 0, Monday as 1, etc.) that occurs on or after the specified date or datetime value.
unixepochReturns the date and time as the number of seconds since 1970-01-01 00:00:00 UTC.
juliandayReturns the Julian day number of a given date or datetime value.
autoAutomatically detects the format of a date or datetime string and converts it to a datetime value.
localtimeConverts a datetime value from UTC to the local timezone.
utcConverts a datetime value from the local timezone to UTC.
subsecReturns the subsecond part of a datetime value.
subsecondReturns the subsecond part of a datetime value as a fractional second.
Was this tutorial helpful ?