Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Query problem with Dates

Author  Topic 

jpradeep
Starting Member

8 Posts

Posted - 2006-11-08 : 06:15:17
Hi All

This is my query

select dateadd(d,Targetdays,BookingDate) as TargetDate from Bookings b, Clients c where b.intClientID=c.intClientID

Here BookingDate is DateTime field and belongs to Bookings Table
and Targetdays is int field and belongs to Clients Table

TargetDate should display BookingDate + TargetDays

Upto here everything okay.

Incase TargetDays contains NULL value or value '0' then
it should display BookingDate + 1 day

How to do it in SQL Query?

Thanks in Advance

Pradeep

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-11-08 : 06:22:28
[code]select dateadd(d, case IsNull(Targetdays,0) when 0 then 1 else Targetdays end,BookingDate) as TargetDate
from Bookings b, Clients c where b.intClientID=c.intClientID[/code]

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

jpradeep
Starting Member

8 Posts

Posted - 2006-11-08 : 06:35:47
Hi Harsh

ThanQ very much for your help.

Thanks
Pradeep

Go to Top of Page
   

- Advertisement -