Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding 15 days to a Date 3

Status
Not open for further replies.
Dec 16, 2005
7
US
Hi all,
CR 10, SQL Server 2000.
I am trying to write a formula to add 15 days to a Datetime field. If the Datetime field is null then it should only return zero. I am not sure how to proceed with this. Any help will be appreciated.
Thanks!
 
Try this

Code:
If IsNull({MyTable.DateField}) Then
     0
Else
     DateAdd("d", 15, {MyTable.DateField})

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
GJP is on the right track using dateadd. However, the '0' won't work as it is not a date type.


if not isNULL({mytable.date_field})
then dateadd("d", 15, {mytable.date_field})
else {mytable.date_field}

This returns a NULL rather than a '0'. If that's not ok, there is some function (I don't recall off the top of my head which one) that returns an 'empty' date value.

damon
 
Thank you both for the quick response. Damon, you were right about the '0'. I tried your formula and it works like a charm!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top