473,406 Members | 2,713 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,406 software developers and data experts.

Help needed with DATETIME Arithmetic

Hi,

I have the following query:

SELECT dbo._Fault.id, dbo._Fault.date_created, dbo._Fault.reference,
dbo._Fault.class, dbo._Fault.owner, dbo._Fault.Contact_Name, dbo._Fault.
Product,
dbo._Fault.Problem_Description,
dbo._Fault.Action_Taken, dbo._Fault.Problem_Solution,
dbo._Fault.Duration_start_date, dbo._Fault.Duration_duration,
dbo._Fault.Duration_date_summary,
dbo._Fault.Fault_Status, dbo._Fault.Fault_Source, dbo._Fault.Part_Number,
dbo._Fault.Serial_No,
dbo._Product.id AS PRODUCTID, dbo._Product.description
FROM dbo._Fault LEFT OUTER JOIN
dbo._Product ON dbo._Fault. Product = dbo._Product.id

I need an additional field appended to the end of this (called
'DATECOMPLETED') that will take the 'Duration_start_date' and add the
'Duration_duration' to it - effectively giving me a new datetime field that
is newer than the start date.

I have tried unseccessfully to amend the code but I am afraid my knowledge
of SQL is limited. I would greatly appreciate if someone could show me how
to do this.

Thanks,

Darren
Sep 19 '06 #1
2 2659

Mintyman wrote:
Hi,

I have the following query:

SELECT dbo._Fault.id, dbo._Fault.date_created, dbo._Fault.reference,
dbo._Fault.class, dbo._Fault.owner, dbo._Fault.Contact_Name, dbo._Fault.
Product,
dbo._Fault.Problem_Description,
dbo._Fault.Action_Taken, dbo._Fault.Problem_Solution,
dbo._Fault.Duration_start_date, dbo._Fault.Duration_duration,
dbo._Fault.Duration_date_summary,
dbo._Fault.Fault_Status, dbo._Fault.Fault_Source, dbo._Fault.Part_Number,
dbo._Fault.Serial_No,
dbo._Product.id AS PRODUCTID, dbo._Product.description
FROM dbo._Fault LEFT OUTER JOIN
dbo._Product ON dbo._Fault. Product = dbo._Product.id

I need an additional field appended to the end of this (called
'DATECOMPLETED') that will take the 'Duration_start_date' and add the
'Duration_duration' to it - effectively giving me a new datetime field that
is newer than the start date.

I have tried unseccessfully to amend the code but I am afraid my knowledge
of SQL is limited. I would greatly appreciate if someone could show me how
to do this.

Thanks,

Darren
If Duration_duration is a number and you want it to be the number of
days added to Duration_start_date you would add something like this to
the select list:

dateadd(dd, Duration_duration, Duration_start__date)

Sep 19 '06 #2
Thanks for the reply. That seems to have done the trick :o)

"ZeldorBlat" <ze********@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
>
Mintyman wrote:
>Hi,

I have the following query:

SELECT dbo._Fault.id, dbo._Fault.date_created, dbo._Fault.reference,
dbo._Fault.class, dbo._Fault.owner, dbo._Fault.Contact_Name, dbo._Fault.
Product,
dbo._Fault.Problem_Description,
dbo._Fault.Action_Taken, dbo._Fault.Problem_Solution,
dbo._Fault.Duration_start_date, dbo._Fault.Duration_duration,
dbo._Fault.Duration_date_summary,
dbo._Fault.Fault_Status, dbo._Fault.Fault_Source, dbo._Fault.Part_Number,
dbo._Fault.Serial_No,
dbo._Product.id AS PRODUCTID,
dbo._Product.description
FROM dbo._Fault LEFT OUTER JOIN
dbo._Product ON dbo._Fault. Product =
dbo._Product.id

I need an additional field appended to the end of this (called
'DATECOMPLETED') that will take the 'Duration_start_date' and add the
'Duration_duration' to it - effectively giving me a new datetime field
that
is newer than the start date.

I have tried unseccessfully to amend the code but I am afraid my
knowledge
of SQL is limited. I would greatly appreciate if someone could show me
how
to do this.

Thanks,

Darren

If Duration_duration is a number and you want it to be the number of
days added to Duration_start_date you would add something like this to
the select list:

dateadd(dd, Duration_duration, Duration_start__date)

Sep 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Terry Hancock | last post by:
What do you do when a date or time is incompletely specified? ISTM, that as it is, there is no formal way to store this --- you have to guess, and there's no way to indicate that the guess is...
1
by: Koncept | last post by:
I want to incorporate the datetime and other modules into my class. I am new to Python and would really appreciate some help doing this. class FooBar: def getDate(self): return...
2
by: sdowney717 | last post by:
The field itemdate is a datetime field in sqlserver2000 DB This works fine: Select Id From BookData Where (MONTH(itemdate) = '01') and (DAY(itemdate) = '02') and (YEAR(itemdate) = '2005') order...
12
by: LongBow | last post by:
Hello all, From doing a google serach in the newsgroups I found out that a string can't be returned from a function, but using a char* I should be able to do it. I have spent most of the day...
4
by: Saso Zagoranski | last post by:
Hi! I have created an SqlCommand object and I have set some parameters to it... One of the parameters is of the DateTime type; here is the code: sqlCommand.Parameters.Value =...
2
by: Chris | last post by:
Hello, How can i convert a C++ CTime (4 bytes) into a C# DateTime ? (my CTime is read in a file). Thanks, -- Chris
2
by: Mark | last post by:
Hi.. I'm writing a web service in C# and needs to produce some time_t values in the xml output, and near as I can figure there appears to be a bug in the C# datetime arithmetic. Below is an...
5
by: Simen Haugen | last post by:
Hi. How can I convert a python datetime to a timestamp? It's easy to convert a timestamp to datetime (datetime.datetime.fromtimestamp(), but the other way around...?) -Simen
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...
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
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...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.