Results 1 to 6 of 6

Thread: Date query

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    31

    Lightbulb Date query

    If you enter a record into a database based on its date and want a turnaround in the database of two days is there a way to delete anything thats two days old from the database on a daily basis?

  2. #2
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424

    Re: Date query

    MS Access:
    Code:
    DELETE FROM TableName WHERE Datefield>=#01/01/2005# and DateField<=#02/01/2005#
    SQL Server:
    Code:
    DELETE FROM TableName WHERE DateField>='2005-01-01' and DateField<='2005-01-02'
    Last edited by Deepak Sakpal; Feb 2nd, 2005 at 04:32 AM.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    31

    Re: Date query

    Yes thats a way if it were just for today but tomorow i want to come in and delete things that are two days old also , and every day , is there a method attached to date that can do this do you know?

  4. #4
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424

    Re: Date query

    Create a app containing this query then add this exe to Windows Scheduled Tasks.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    31

    Re: Date query

    ok il try that, thanks, not too sure how tho but il give it A go?

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Date query

    if you want to just do it when you program starts, how about

    VB Code:
    1. Dim d As Date
    2. d = DateAdd("d", 2, Date)

    then run your query against > d

    rgds pete

Posting Permissions

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



Click Here to Expand Forum to Full Width