Results 1 to 12 of 12
  1. #1
    Nortonsapple is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    6

    Update field based on time stamp

    Hello, I have a date field that is using now() as default. If that time stamp is after or before closing time I need another field adjusted with a new time. I have worked out how to adjust time but not how to get the query to check the time portion of the field with the now() time date stamp as criteria.



    I'm not sure if I am saying what I need correctly and your help and direction is most appreciated!

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Datepart function sounds like what you need.


    Sent from my iPhone using Tapatalk

  3. #3
    Nortonsapple is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    6
    I've tried it but I don't think I'm doing right. I used :
    >datepart(hh,[my date field],#6:00:00#)

    In the criteria section for the date time stamp field.
    Which did not work. I'm just missing it in a major way. I need it to find time stamps in that field that came in before 8:30am and after 6:00 pm. Variations that I have come up with pull all times or none with a error. Thank you for helping me!
    Last edited by Nortonsapple; 02-19-2017 at 04:00 AM. Reason: Add more detail

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,540
    I think you will need something like:
    Code:
    a: IIf(TimeValue(DatePart("h",[YourDate]) & ":" & DatePart("n",[YourDate]))>"08:30","LaterCalc","EarlierCalc")
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    Nortonsapple is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    6
    Thanks! I'll try it as soon as I get in. My VMware connection isn't playing fair this morning. I hadn't even considered a iff then statement. I haven't used them in access before. Would i place it in the update field or the criteria field of a update query or would this be the criteria in a select query? I apologize for my "newbness". I'm learning as I go.

  6. #6
    Nortonsapple is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    6
    I'm thinking the update cell of "new time" field, right?

  7. #7
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,792
    I have worked out how to adjust time but not how to get the query to check the time portion of the field with the now() time date stamp as criteria
    Not sure I understand where the IIF part comes in. If you already know how to make the adjustment, isn't the issue about how to get the hour part of date/time?

    Code:
    WHERE ((DatePart("h",[aTime]))=7)
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    Nortonsapple is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    6
    WHERE ((DatePart("h",[aTime]))=7) works but how do I account for pm versus am? I tried using military time but it didn't do as expected.

  9. #9
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Code:
    WHERE ((DatePart("h",[aTime]))=7)
    Id suggest playing around with "or 19"

  10. #10
    Nortonsapple is offline Novice
    Windows 8 Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    6
    Or 19 got a data type mismatch. When I tried using >18 it did pull up those after 6pm but still had a few AMs too.

  11. #11
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    how about

    Code:
    WHERE ((DatePart("h",[time])=7)) OR ((DatePart("h",[time])=19));

  12. #12
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,792
    Quote Originally Posted by Nortonsapple View Post
    Or 19 got a data type mismatch. When I tried using >18 it did pull up those after 6pm but still had a few AMs too.
    Since there was no OR in my example, posting your attempt would have been helpful. This this is what I get using DatePart("h",[RequestDate])=14
    DeptID RequestDate
    1 12/11/15 2:13:39 PM
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 04-01-2015, 01:29 AM
  2. Replies: 9
    Last Post: 07-21-2014, 11:57 AM
  3. Date and Time Stamp
    By zoooza84 in forum Access
    Replies: 2
    Last Post: 08-06-2011, 04:53 AM
  4. Time Stamp when field is populated
    By suncluster in forum Access
    Replies: 1
    Last Post: 06-13-2011, 01:39 PM
  5. Question about Button and Time Stamp
    By euroclyde in forum Access
    Replies: 2
    Last Post: 06-16-2010, 09:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums