Results 1 to 9 of 9
  1. #1
    renaccess1 is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Posts
    8

    Creating a New Column End Date in a query


    Hello I would like to create the following is this doable in access?
    Table #1
    PROC_NM TBL_KEY TBL_LAST_DT
    R_BOND_STA 251,826,400,HELI 11/15/2016 12:48:53
    R_BOND_STA 251,826,400,HELI 11/22/2016 11:07:25
    R_BOND_STA 251,826,400,HELI 2/25/2016 14:33:46
    Results Table
    PROC_NM TBL_KEY Begin Date End Date
    R_BOND_STA 251,826,400,HELI 2/25/2016 14:33:46 11/15/2016 12:48:52
    R_BOND_STA 251,826,400,HELI 11/15/2016 12:48:53 11/22/2016 11:07:25
    R_BOND_STA 251,826,400,HELI 11/22/2016 11:07:26 Current Ddate
    would like to create new column with an end range

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I'm pretty sure this can be accomplished. What are the calculations needed to create the value?

  3. #3
    renaccess1 is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Posts
    8
    What I am really trying to create is a query that shows the dates when a status has changed and trying to figure out the best way to do this... thats my challenge I a trying to do this but not ending the result table


    PROC_NM TBL_KEY ORIG_VAL NEW_VAL TBL_LAST_DT
    R_BOND_STA 251,826,400,HELI AA 11/15/2016 12:48:53
    R_BOND_STA 251,826,400,HELI AA WW 11/22/2016 11:07:25
    R_BOND_STA 251,826,400,HELI 2/25/2016 14:33:46
    Result table
    PROC_NM TBL_KEY ORIG_VAL NEW_VAL TBL_LAST_DT End Date
    R_BOND_STA 251,826,400,HELI AA 11/15/2016 12:48:53 11/22/2016 11:07:24
    R_BOND_STA 251,826,400,HELI AA WW 11/22/2016 11:07:25 2/25/2016 14:33:45
    R_BOND_STA 251,826,400,HELI 2/25/2016 14:33:46 Current date and time

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Okay, now I understand. Maybe a "Get the value in another record" SubQuery will work: http://allenbrowne.com/subquery-01.html

  5. #5
    renaccess1 is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Posts
    8
    Will see .. any other options?

  6. #6
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    Not very clear what you want.
    Why do some records in table have and end date and others not?
    When do you want to update the table end date? Whenever it is viewed in a form? Or run an update query once a day to check for incomplete records?
    We don't know enough about your data flow and operational processes to help much here...
    Code:
    SELECT tblInformation.*, Date() AS NewDate
    FROM tblInformation;
    To simply add a new current date field to every row in a query do above.

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You could brute force it with a RecordSet and come looping code.

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by davegri View Post
    Why do some records in table have and end date and others not?
    I could be wrong but I believe the OP is faced with a Next record date issue and when there are no additional records in this series, insert the current date.

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The more I think about it, the more convinced I am that the SubQuery would be the way to go. You would be looking for the TBL_LAST_DT in a record with a TBL_LAST_DT > that the record you're on. If no records exist (your on the last record of the sequense) then I would expect a Null to be returned I think.

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

Similar Threads

  1. Replies: 4
    Last Post: 07-26-2016, 02:39 AM
  2. Replies: 4
    Last Post: 12-29-2015, 03:25 PM
  3. Replies: 23
    Last Post: 04-08-2015, 12:38 PM
  4. Replies: 3
    Last Post: 09-19-2012, 08:59 AM
  5. Replies: 0
    Last Post: 02-14-2007, 01:35 PM

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