473,396 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do I add 12 hours to NOW()

The following code allows a list of seminars to display on a homepage:

Expand|Select|Wrap|Line Numbers
  1. $sql = 'SELECT ID,title,division,startdate,enddate,time,location 
  2.                FROM event 
  3.                WHERE category="1" AND startdate > NOW()
  4.                ORDER BY startdate, enddate 
  5.                LIMIT 4';
The first seminar will only show up until the time of the conference. I would like for it to display for 12 hours after the conference occurs. How do I make that happen?
Sep 29 '10 #1
3 3925
dlite922
1,584 Expert 1GB
Issa Fox, welcome to Bytes!

In this instance you can do it with PHP and replace NOW() with a calculated time, but I suggest you go the MySQL route because it's quicker.

http://dev.mysql.com/doc/refman/5.1/...ction_date-add

like so: DATE_ADD(NOW(),INTERVAL 12 HOURS)

Cheers,

Dan
Sep 29 '10 #2
HaLo2FrEeEk
404 256MB
Or:

strtotime("+12 hours")

Should also work, and saves you from calling the now() function AND the date_add() function.
Oct 4 '10 #3
dlite922
1,584 Expert 1GB
There's only one way to settle this: Benchmarking.

Somebody should create a 1,000,000 row table with a string and a random date 1979-Present. Then run +12 hour Select commands on a random number of records 1-n at a time using each of the methods.

My bets are on MySQL.

Cheers!

Dan
Oct 4 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Darren | last post by:
Hello, How would I write in SQL or ASP the following?: Count number of Database Records between NOW and 24 HOURS EARLIER? I know how to retrieve recordsets etc - its just the date thing I cant...
1
by: sg_s123 | last post by:
============================================================================ 02-Feb-04 03-Feb-04 Staff Staff 0800hr- 1300hr- 1700hr- 1900hr- 0800hr- 1300hr- 1700hr- 1900hr- Number...
5
by: Rebecca Smith | last post by:
I'm building log book to keep track of a racers stats during a long ultra marathon race. Things such as time on the bike, time off, H20 intake, electrolytes and the like. When I say long I mean...
10
by: B Moor | last post by:
Host PC: Win SBS 2003 with 2.6 GHz processor and 1GB RAM SQL Server 2000 sp3 (or latest).MS Office 2k3 I have the access 2k3 front end running on server (this may get changed) and all was well...
1
by: serge | last post by:
Right now the database I am working with is storing time in an Integer data type and is storing the time value in seconds. The application does not allow entering seconds. It accepts minutes and...
22
by: Drum2001 | last post by:
I have a table that tracks employee times. I have a column (Date/Time). Users, through a form, enter how long it takes them to complete a task. For example, 03:45 = 3 hours and 45 mins. I am...
2
by: David | last post by:
We've developed a seismic-data processing app in VB.NET 1.1 which runs on XP Pro using SQL2K. Like all seismic data apps, it deals with HUGE amounts of binary data (we use NTFS sparse "flat...
6
by: richbneal | last post by:
I really like the site so far and this is my first post. I have looked through some of the archives with no luck. I have also read the posting guidelines and will do my best to be clear and accurate...
23
by: tatata9999 | last post by:
Hi, What time zones tend to use 24 hours time format? Googling hasn't been able to answer the question. Thank you.
10
by: viki1967 | last post by:
Help with check date and hours Hi all. I have this form: <html> <head>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.