Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Programming (http://www.go4expert.com/forums/programming-forum/)
-   -   Difference in Days between two date fields. (http://www.go4expert.com/forums/difference-days-date-fields-t19078/)

agreenvbman 17Aug2009 21:53

Difference in Days between two date fields.
 
Hello,

I have to find the difference between two date fields. I have a system date which I have defined as Date in my form. I also have a Date Modified field. I want to subtract the Date Field from the date Modified field and get a total days variable. I will use this Total Days variable in an If Statement to determine whether other fields can be changed or not. I do not want any field changed after five days on the form. If the the TotalDays variable equals 5, I will not let any changes be saved. If the TotalDays is less than five, I will let changes be made to fields.

Is there a way in VB to do this?

agreenvbman

nimesh 23Aug2009 03:21

Re: Difference in Days between two date fields.
 
you should get the result by a direct subtract statement
Did you already tried it?

agreenvbman 29Aug2009 18:57

Re: Difference in Days between two date fields.
 
I am trying to use a Sequel Server 2005 database table called CallIssueMain to find the records with DateTimeAdded less than 6 days.

I am trying to write the Tsequel coding like this, but getting an error. What is wrong with my coding inside the Query window?

The Coding:

Declare @EndDate smalldatetime, @StartDate smalldatetime

set @StartDate = dateadd(dd,-6,getdate())
set @EndDate = getdate()

Select ID, Issue, Resolution, DateTimeAdded,FROM CallIssueMainWHERE User= @UserName and Date between @StartDate and @EndDate



The error I get is:

ERROR PARSING QUERY.[TOKEN LINE NUMBER = 1, TOKEN LINE OFFSET = 1, TOKEN IN ERROR = DECLARE]
ERROR SOURCE: ADO.NET DATA PROVIDER

nimesh 29Aug2009 20:01

Re: Difference in Days between two date fields.
 
Looks like its the problem in the Declare statement
TOKEN IN ERROR = DECLARE

Check if this helps:
http://www.experts-exchange.com/Prog..._24479076.html

shabbir 30Aug2009 08:46

Re: Difference in Days between two date fields.
 
experts-exchange.com will not allow to see the answer unless you are an expert member or paid member.

nimesh 30Aug2009 19:48

Re: Difference in Days between two date fields.
 
1 Attachment(s)
Quote:

Originally Posted by shabbir (Post 56435)
experts-exchange.com will not allow to see the answer unless you are an expert member or paid member.

Yes, that's true
but today after your reply I found something which I didn't noticed earlier

If you go to expert-exchange from google it shows you the answer at the bottom of the page, but if you go directly, then it doesn't

check the attached page which I got after googling :lol:

till now even I was in question whether they have changed the policy or is it just me than I can see the answers.

it might be only 2-3 times that I was unable to see the answer, but most of the time I did see.
I think google is the reason :rofl:

shabbir 30Aug2009 22:03

Re: Difference in Days between two date fields.
 
I never scrolled that down but yes may be may be not. Who cares. I believe in information and knowledge should be open to all.


All times are GMT +5.5. The time now is 12:41.