051119 Posted January 2, 2010 Share Posted January 2, 2010 Hi all, I've got 2 tables as below: stops Stop_name RouteNumb Order Min_from_start routes RouteNumb Start_time In essence, Start_time contains the time the bus sets out on its journey, and Min_from_start is how many minutes from the first stop the bus is (eg. so if Start_time is 09:00 and Min_from_start is 14, then I'm looking for 09:14). Can anyone please help me find an SQL query to calculate this? So far I've got SELECT stops.Stop_name, stops.Min_from_start, routes.Start_time FROM routes INNER JOIN stops ON Routes.RouteNumb = stops.route WHERE (((stops.route)="12")); Which shows the info but not the times. Thank you so much! Quote Link to comment https://forums.phpfreaks.com/topic/186952-additions-in-sql/ Share on other sites More sharing options...
Mchl Posted January 2, 2010 Share Posted January 2, 2010 Assuming you store Start_time as TIME SELECT stops.Stop_name, stops.Min_from_start, routes.Start_time, routes.Start_time + INTERVAL stops.Min_from_start MINUTE AS stopTime FROM routes INNER JOIN stops ON Routes.RouteNumb = stops.route WHERE (((stops.route)="12")); Quote Link to comment https://forums.phpfreaks.com/topic/186952-additions-in-sql/#findComment-987241 Share on other sites More sharing options...
051119 Posted January 2, 2010 Author Share Posted January 2, 2010 Thank you ever so much for your reply! Access throws up this error though Syntax error (missing operator) in query expression 'routes.Start_time + INTERVAL stops.Min_from_start MINUTE'[/Quote] I've tried playing around with it a bit but can't work out what it's after. Would be grateful for any help! Regards Quote Link to comment https://forums.phpfreaks.com/topic/186952-additions-in-sql/#findComment-987316 Share on other sites More sharing options...
Mchl Posted January 2, 2010 Share Posted January 2, 2010 If you want Access help, don't ask in MySQL forum. Sorry. Moving to MSSQL. Quote Link to comment https://forums.phpfreaks.com/topic/186952-additions-in-sql/#findComment-987328 Share on other sites More sharing options...
051119 Posted January 3, 2010 Author Share Posted January 3, 2010 Sorry, didn't realise there was a difference! If anyone can help I would be very grateful, I've been racking my brains for hours over this! Quote Link to comment https://forums.phpfreaks.com/topic/186952-additions-in-sql/#findComment-987572 Share on other sites More sharing options...
051119 Posted January 3, 2010 Author Share Posted January 3, 2010 Nevermind, I've got it thanks! I used DateAdd in Access! Quote Link to comment https://forums.phpfreaks.com/topic/186952-additions-in-sql/#findComment-987576 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.