Calculations on a Date Field

# Thread: Calculations on a Date Field

1. dep
Senior Member
Join Date
Dec 1969
Posts
709

## Calculations on a Date Field

Hello. I have a date field in my database (mm/dd/yyyy) -- I would like to have something happen if the date in the database is within a certain range to today&#039;s date. If the date is within 30 days, do something.. If within 120, do something else... Any ideas on how to do this? Any documentation anywhere? Thanks for any help. Not sure how to go about it.<BR><BR>dep<BR>

2. Senior Member
Join Date
Dec 1969
Posts
450

## RE: Calculations on a Date Field

If you are using SQL Server searcg for :<BR><BR> DATEADD Function in BOL (day, -1, getdate())<BR>ex:<BR><BR>Create Procedure hello @DateValue datetime<BR>as<BR>declare @DateValue2 as datetime<BR>set DateValue2 = DateAdd(day,-30, getdate())<BR>if @DateValue &#060; DateValue2 <BR> begin<BR> -- do something like select a range from a table<BR> end<BR><BR>if @DateValue &#062; DateValue2 <BR> begin<BR> -- do something like select a range from a table<BR> end<BR>go

3. Senior Member
Join Date
Dec 1969
Posts
201

## RE: Calculations on a Date Field

check out <BR><BR>http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=48<BR><BR>http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=183

4. dep
Senior Member
Join Date
Dec 1969
Posts
709

## RE: Calculations on a Date Field

i just sortof did:<BR><BR>temp = RS(4) - date()<BR><BR>If temp &#060; 30 then<BR> do this<BR>end if<BR><BR>where RS(4) was the database field that had the date for that record...<BR><BR>anyway, thanks for the help :)<BR><BR>dep<BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•