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

  • Home
  • SEARCH
  • 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 756739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:16:46+00:00 2026-05-14T15:16:46+00:00

In short, how to add minutes to a datetime from an integer located in

  • 0

In short, how to add minutes to a datetime from an integer located in another table, in one select statement, by joining them, in sqlite3?

I have a sqlite3 db with:

table P(int id, …, int minutes)
and a table S(int id, int p_id, datetime start)

I want to generate a view that gives me PS(S.id, P.id, S.start + P.minutes) by joining S.p_id=P.id

The problem is, if I was generating the query from the application, I can do stuff like:

select datetime('2010-04-21 14:00', '+20 minutes');
2010-04-21 14:20:00

By creating the string ‘+20 minutes’ in the application and then passing it to sqlite. However I can’t find a way to create this string in the select itself:

select p.*,datetime(s.start_at, formatstring('+%s minutes', p.minutes)) from p,s where s.p_id=p.id;

Because sqlite as far the documentation tells, does not provide any string format function, nor can I see any alternative way of expressing the date modifiers.

In MySQL, the date modifiers are not based on strings, so it actually works:

mysql> create table p ( id integer, minutes integer);
mysql> create table s ( id integer, p_id integer, start datetime);
mysql> insert into p values (1, 10);
mysql> insert into p values (2, 15);
mysql> insert into s values (1, 1, '2008-12-31 14:00');
mysql> insert into s values (2, 1, '2008-12-31 15:00');
mysql> insert into s values (3, 2, '2008-05-10 13:30');
mysql> SELECT p.*,(s.start + INTERVAL p.minutes MINUTE) FROM p,s WHERE p.id=s.p_id;
+------+---------+---------------------------------------+
| id   | minutes | (s.start + INTERVAL p.minutes MINUTE) |
+------+---------+---------------------------------------+
|    1 |      10 | 2008-12-31 14:10:00                   | 
|    1 |      10 | 2008-12-31 15:10:00                   | 
|    2 |      15 | 2008-05-10 13:45:00                   | 
+------+---------+---------------------------------------+
3 rows in set (0.02 sec)
  • 1 1 Answer
  • 1 View
  • 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-14T15:16:47+00:00Added an answer on May 14, 2026 at 3:16 pm

    Concatenation did not work using +. However the || concatenation operand did work as expected.

    So MySQL’s

    SELECT p.*,(s.start + INTERVAL p.minutes MINUTE) FROM p,s WHERE p.id=s.p_id;
    

    Can be written in sqlite3 as:

    select p.*, datetime(s.start, '+' || p.minutes || ' minutes') from p, s where s.p_id=p.id;
    

    Which produces the correct answer. Thanks to newtover for pointing in the right direction.

    1|10|2008-12-31 14:10:00
    1|10|2008-12-31 15:10:00
    2|15|2008-05-10 13:45:00
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Short: how does modelbinding pass objects from view to controller? Long: First, based on
Data from another system is replicated into a SQL Server 2005 database in real-time
Short and sweet summary: When changing a class from View -derived to ViewGroup -derived,
Short version: I want to trigger the Form_Load() event without making the form visible.
Short version: I'm wondering if it's possible, and how best, to utilise CPU specific
Short of cutting and pasting, is there a way to sort the methods in
Short of putting a UIWebView as the back-most layer in my nib file, how
Short version: assuming I don't want to keep the data for long, how do
Short of copying the entire .netbeans directory is there any way to transfer custom
Short Version: When I've created a Channel using ChannelFactory on a client which uses

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.