473,382 Members | 1,147 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,382 software developers and data experts.

Run a query on datetime minus 2 days

nathj
938 Expert 512MB
Hi,

I'm currently developing a web system that allows people to register for the various events my organisation hosts.
I have completed the online registration system and now need to mnake a few enhancements.

The one enhancement I'm a bit stuck on is how to select a date minus 2 days. This would enable me to close the online registration two days before the event.

In the table I have a field, startime which shows the dtaetime that the event will start. If the event starts on 18/10/2007 at 6pm I need to close the registration link on 16/10/2007. so it's just the day that this is based on and not the time.

I'm sure there must be a way of doing this but I can't figure it out.

Any help greatly appreciated.
nathj
Sep 28 '07 #1
1 6094
nathj
938 Expert 512MB
Hi I thought I should post back as found the solution whilst playing around with something else.

I have now selected an extra colum in my SQL using the date_format(date_sub)) functions to get exactly what I wanted.
Expand|Select|Wrap|Line Numbers
  1. date_format(date_sub(a.starttime, interval 2 day), '%Y-%m-%d') as closeRegistration
  2.  

Thats the snippet of the SQL select statement that does the trick.

Many thanks
nathj
Sep 28 '07 #2

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

Similar topics

7
by: Fred Thompson | last post by:
I'm using MS SQL 2000 server. I have a table which includes a date field which has people's birthdays in it. How can I write a query to return all the records of people with birthdays within the...
4
by: sah | last post by:
I need some help with the following query: DECLARE @SRV VARCHAR(20), @date smalldatetime SET @SRV = (select @@servername) SET @date = '20040901' select Srv_Name = @SRV, DB_Name = 'DB_NAME',...
3
by: Myron | last post by:
I'm trying to create a query that will tell me which requests took longer than 10 days to move one from particular state to another state. The query I've created returns the correct requests, but...
5
by: The Pig | last post by:
Got a table. Date Time Code 1/1/2003 1700 xbc 1/1/2003 1800 xbc 1/1/2003 1800 xbc 2/4/2004 1650 abc 2/4/2004 1700 abc The problem is I need a...
3
by: CBN Media | last post by:
Hi, I need to calculate a date which is current date (Now) minus x days. I looked at DateTime, it has a fairly large number of methods to add something to a date, but for substracting is just...
11
by: Andy_Khosravi | last post by:
My problem: I'm having trouble with a query taking much too long to run; a query without any criteria evaluating only 650 records takes over 300 seconds to run (over the network. On local drive...
4
by: JayCallas | last post by:
I have a SQL 2000 table containing 2 million rows of Trade data. Here are some of the columns: INT IDENTITY(1,1) -- PK, non-clustered DATETIME -- clustered index ...
3
by: Dinesh | last post by:
Hi Experts, I am working on SSRS 2005, and I am facing a problem in counting the no of days. My database has many fields but here I am using only two fields They are Placement_Date and...
2
by: Rene A | last post by:
Hi, I want to get the current date minus 60 days, how can i do that. This is what i have /want: DateTime now = DateTime.Now; Result = DateTime.Now.ToString("yyyyMMdd") + "')-60; it must...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.