Getting first record of the day

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Getting first record of the day



    I need help getting the right SQL statement . I would like to grab the
    first record of the day (records have a date entry and a time entry
    associated with them.

    I know it is going to be a select statement, but the right syntax eludes
    me (these late nights and early mornings makes the brain a little
    foggy).

    Any help would be appreciated.


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    HallMonitor89 Guest

  2. Similar Questions and Discussions

    1. How can i retrieve record ONLY From 300 - 400 in amillion Record Table?
      HI all Thanks for your time.. I have a question here.. How can i retrieve record ONLY From XXX - XXX in a million Record Table? eg. I have a...
    2. Find record w/ conditions met in the same child record
      I'll use 2 files to demonstrate my question. The first file is Animal. It has 4 fields. Id (serial number) ZooId (number) Name (text) Food...
    3. using dropdown box to display db record & update record
      Hi Folks, I have a web database written in asp and using access97. I have many projects, but each project is being held responsible by a person....
    4. Stop adding record in subform after record count = 1
      Can someone help in in what to put after the THEN statment to allow one entry if the Record count is =>1 in the Before insert or should I set the...
    5. Adding a new record when the record source is a query.
      Hello All, I have a form that runs a query. The reason it runs on a query is because prior to it opening I have a form from which you can pick...
  3. #2

    Default Re: Getting first record of the day

    What kind of database?

    Ray at work

    "HallMonitor89" <nospam@novirus.com> wrote in message
    news:O241UANwDHA.2472@TK2MSFTNGP09.phx.gbl...
    >
    >
    > I need help getting the right SQL statement . I would like to grab the
    > first record of the day (records have a date entry and a time entry
    > associated with them.
    >
    > I know it is going to be a select statement, but the right syntax eludes
    > me (these late nights and early mornings makes the brain a little
    > foggy).
    >
    > Any help would be appreciated.
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Ray at Guest

  4. #3

    Default Re: Getting first record of the day

    On Fri, 12 Dec 2003 12:54:08 -0500, "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote:
    >What kind of database?
    >
    >Ray at work
    >
    >"HallMonitor89" <nospam@novirus.com> wrote in message
    >news:O241UANwDHA.2472@TK2MSFTNGP09.phx.gbl...
    >>
    >>
    >> I need help getting the right SQL statement . I would like to grab the
    >> first record of the day (records have a date entry and a time entry
    >> associated with them.
    >>
    >> I know it is going to be a select statement, but the right syntax eludes
    >> me (these late nights and early mornings makes the brain a little
    >> foggy).
    >>
    >> Any help would be appreciated.
    >>
    >>
    >> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    >> Don't just participate in USENET...get rewarded for it!
    >
    In general:
    ( Sql varies between databases, so this will work on Oracle - altho it may be different for some versions-, for
    instance, but may not work in Access or SqlServer )

    select * from table where date_entry = sysdate and time_entry = (select min(time_entry) from table where date_entry =
    sysdate);

    The idea is to get today's records and then test for the earliest time..

    hth,

    Turkbear Guest

  5. #4

    Default Re: Getting first record of the day



    Database is Access 2k. Contains 1 table. Very Simple Database.
    Columns are CustName, Date, Time, OrderID

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    HallMonitor89 Guest

  6. #5

    Default Re: Getting first record of the day

    You have separate columns for date and time? Hmm. In that case:

    SELECT TOP 1 [CustName],[Date],[Time],[OrderID] FROM Table1 WHERE
    [Date]=Date() ORDER BY [Time]

    If you had just one column that had date and time,

    SELECT TOP 1 Custname,EntryTime,OrderID FROM Table1 WHERE
    DateDiff('d',EntryTime,Date()) = 0 ORDER BY EntryTime

    Ray at work






    "HallMonitor89" <nospam@novirus.com> wrote in message
    news:uSp%23M4NwDHA.3416@tk2msftngp13.phx.gbl...
    >
    >
    > Database is Access 2k. Contains 1 table. Very Simple Database.
    > Columns are CustName, Date, Time, OrderID
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Ray at Guest

  7. #6

    Default Re: Getting first record of the day


    That works, thanks.

    I know it would be more ideal to have the date and time in the same
    column (it sure would help with other programming aspects).


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    HallMonitor89 Guest

  8. #7

    Default Re: Getting first record of the day


    "HallMonitor89" <nospam@novirus.com> wrote in message
    news:uppDnZOwDHA.1744@TK2MSFTNGP12.phx.gbl...
    > I know it would be more ideal to have the date and time in the same
    > column (it sure would help with other programming aspects).
    >
    There's plusses and minuses to both ways, I'd say. This is something you
    should be more aware of though:
    [url]http://www.aspfaq.com/show.asp?id=2080[/url]

    Ray at work


    Ray at Guest

  9. #8

    Default Re: Getting first record of the day

    > I know it would be more ideal to have the date and time in the same
    > column
    And in some databases, you don't have much choice.
    [url]http://www.aspfaq.com/2206[/url]
    > (it sure would help with other programming aspects).
    So why not add a column with the combined information?

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]



    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Aaron Bertrand [MVP] Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139