Results 1 to 4 of 4

Thread: Need help with using TimeStamps from Database

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    Need help with using TimeStamps from Database

    I am building an application that runs once every two hours during the day. Its purpose is to check a database to see if there have been any orders placed in the last two hours (since the last time it was run). The Ordering system adds a timestamp to the table so I am thinking that is the best way to track orders.

    My first thought was to have my program look at the current time then subtract two hours from it and pull the orders that way. The problem with that is that if for some reason the program doesn't run at the time it should I may miss an order or two.

    So I think I am going to have to do is store the last timestamp somewhere and then look for orders based on the Current Time minus the last timestamp. Does that sound right? If so I think the best way to accomplish that would be to store the timestamp in an XML file for quick reference. Any other ideas, thoughts or suggestions?

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: Need help with using TimeStamps from Database

    That sounds like the best idea. Just save the date you last requested orders, and only ask for new orders since that date. That means if you miss one slot, the next one will pick up 4 hours, not just 2. No need to do any date calculations at all.

    ie
    savedate = nothing 'first run
    get orders since forever
    save date to xml
    ...
    2 hours later
    load date from xml
    get orders since this date
    save current date to xml

    etc etc

  3. #3
    Hyperactive Member ProphetBeal's Avatar
    Join Date
    Aug 2006
    Location
    New York
    Posts
    424

    Re: Need help with using TimeStamps from Database

    Other idea is if this table you are looking at contains a unique incrimental field like an order number...you could just store that last order number processed then the next time your program runs it will only look at order numbers that are greater than the last 1 processed.

    Helpful Links:
    VB 6 - How to get the "Key" Value in a collection
    VB.NET - File Search Utility || VB.NET - How to compare 2 directories || VB.NET - How to trust a network share
    VB.NET - Create Excel Spreadsheet From Array || VB.NET - Example Code & Hints you may not know
    VB.NET - Save JPEG with a certain quality (image compression) || VB.NET - DragDrop Files, Emails, and Email Attachments

    Please post some of the code you need help with (it makes it easier to help you)
    If your problem has been solved then please mark the thread [RESOLVED].
    Don't forget to Rate this post

    "Pinky, you give a whole new meaning to the phrase, 'counter-intelligence'."-The Brain-

  4. #4
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780

    Re: Need help with using TimeStamps from Database

    That would be a better solution, as you dont have to worry about your PC being out of date in comparison with the database, or if you run it from two or more computers.

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