Difference in Days between two date fields.

Discussion in 'Programming' started by agreenvbman, Aug 17, 2009.

  1. agreenvbman

    agreenvbman New Member

    Joined:
    Aug 17, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  2. nimesh

    nimesh New Member

    Joined:
    Apr 13, 2009
    Messages:
    769
    Likes Received:
    20
    Trophy Points:
    0
    Occupation:
    Oracle Apps Admin
    Location:
    Mumbai
    Home Page:
    http://techiethakkar.blogspot.com
    you should get the result by a direct subtract statement
    Did you already tried it?
     
  3. agreenvbman

    agreenvbman New Member

    Joined:
    Aug 17, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  4. nimesh

    nimesh New Member

    Joined:
    Apr 13, 2009
    Messages:
    769
    Likes Received:
    20
    Trophy Points:
    0
    Occupation:
    Oracle Apps Admin
    Location:
    Mumbai
    Home Page:
    http://techiethakkar.blogspot.com
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    experts-exchange.com will not allow to see the answer unless you are an expert member or paid member.
     
  6. nimesh

    nimesh New Member

    Joined:
    Apr 13, 2009
    Messages:
    769
    Likes Received:
    20
    Trophy Points:
    0
    Occupation:
    Oracle Apps Admin
    Location:
    Mumbai
    Home Page:
    http://techiethakkar.blogspot.com
    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:
     
  7. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice