Skip to content

Vb.net, sql and dates

martin escalante

Asked Nov 11, 2010, 3:58 AM EST1 answer
Share
LinkedInX
Hi,
this is about replacing batteries every year. im using vb.net2008, msaccess2007. i need the right sql statement that will show me the devices that need replacement after a year(365 days). i want to compute the last-date-installed against current-date(today's date). and this is done from vb.net. any input, ideas, suggestions is greatly appreciated.
thank you very much in advance
p.s. if this is not the right forum, would you redirect me to the right one.
thanks again

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Jiteendra Sampathirao
    0
    Hi,
    Use the Date difference method.

    Datediff: Returns the count (signed integer) of the specified datepart boundaries crossed between the specified startdate and enddate.

    Syntax:
    Code
    DATEDIFF (datepart ,startdate ,enddate )
    
    example:
    SELECT DATEDIFF(year, '2005-12-31 23:59:59.9999999', '2006-01-01 00:00:00.0000000')as Days;

    C#
    And write the if condition like 
    
    if (days>=365)
    {
    //your business logic goes here
    }
    
    
    If this post helped you, then tick the "Do you like this Answer" checkbox which is placed at above this post.
    0