Results 1 to 13 of 13
  1. #1
    sdc1234 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    89

    Date fields

    Greetings, I am trying to run a query that will give me <=Now()-7 on my end dates column, Is there a way to get this done without converting back to Julien Dates, any help would be appreciated



    v/r
    Novice

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Convert from what? Why would anything need to be converted?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    sdc1234 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    89
    I don't know but I am trying to separate courses taken by less than today's date -7 days on my start date column and then extract the rest of the courses to a different table < today's date which I have already extracted

  4. #4
    sdc1234 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    89
    I'm trying to use regular date fields ex.(11/01/2014)

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    The criteria you posted should work on a date/time field. What happens - error message, wrong results, nothing? Post the query SQL statement.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    sdc1234 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    89
    Give me a few hrs I have to go to some meetings when I get back I will post the 2 queries 1 extracts the future classes and the other extracts the previous (it doesn't) it no error msg or anything

  7. #7
    sdc1234 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    89
    SELECT [03b-Initialize NETC Updates].SID, [03b-Initialize NETC Updates].PID, [03b-Initialize NETC Updates].Cadre, [03b-Initialize NETC Updates].[Position Code], [03b-Initialize NETC Updates].LName, [03b-Initialize NETC Updates].FName, [03b-Initialize NETC Updates].MInital, [03b-Initialize NETC Updates].Code1, [03b-Initialize NETC Updates].Code2, [03b-Initialize NETC Updates].[Course Code], [03b-Initialize NETC Updates].[Course Title], [03b-Initialize NETC Updates].[Start Date], [03b-Initialize NETC Updates].[End Date], [03b-Initialize NETC Updates].[Organization Name], [03b-Initialize NETC Updates].[Organization City], [03b-Initialize NETC Updates].State, [03b-Initialize NETC Updates].Zip, [03b-Initialize NETC Updates].Pass, [03b-Initialize NETC Updates].Jurisdiction, [03b-Initialize NETC Updates].[Business Type], [03b-Initialize NETC Updates].STATUS, [03b-Initialize NETC Updates].TYPE, [03b-Initialize NETC Updates].SALARY, [03b-Initialize NETC Updates]![SID]+[03b-Initialize NETC Updates]![PID]+[03b-Initialize NETC Updates]![LName]+[03b-Initialize NETC Updates]![Course Code]+Format([03b-Initialize NETC Updates]![Start Date],"mm/dd/yyyy")+Format([03b-Initialize NETC Updates]![End Date],"mm/dd/yyyy") AS [select]
    FROM [03b-Initialize NETC Updates]
    WHERE (((IIf([03b-Initialize NETC Updates]![End Date]<=Now()-7,1,0))=1))
    GROUP BY [03b-Initialize NETC Updates].SID, [03b-Initialize NETC Updates].PID, [03b-Initialize NETC Updates].Cadre, [03b-Initialize NETC Updates].[Position Code], [03b-Initialize NETC Updates].LName, [03b-Initialize NETC Updates].FName, [03b-Initialize NETC Updates].MInital, [03b-Initialize NETC Updates].Code1, [03b-Initialize NETC Updates].Code2, [03b-Initialize NETC Updates].[Course Code], [03b-Initialize NETC Updates].[Course Title], [03b-Initialize NETC Updates].[Start Date], [03b-Initialize NETC Updates].[End Date], [03b-Initialize NETC Updates].[Organization Name], [03b-Initialize NETC Updates].[Organization City], [03b-Initialize NETC Updates].State, [03b-Initialize NETC Updates].Zip, [03b-Initialize NETC Updates].Pass, [03b-Initialize NETC Updates].Jurisdiction, [03b-Initialize NETC Updates].[Business Type], [03b-Initialize NETC Updates].STATUS, [03b-Initialize NETC Updates].TYPE, [03b-Initialize NETC Updates].SALARY, [03b-Initialize NETC Updates]![SID]+[03b-Initialize NETC Updates]![PID]+[03b-Initialize NETC Updates]![LName]+[03b-Initialize NETC Updates]![Course Code]+Format([03b-Initialize NETC Updates]![Start Date],"mm/dd/yyyy")+Format([03b-Initialize NETC Updates]![End Date],"mm/dd/yyyy");

  8. #8
    sdc1234 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    89
    thats the one that will not work

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Format function results in a string value so yes, think you need to convert back to date/time type. Can wrap the expression into CDate().
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    sdc1234 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    89
    can you give me an example of how I would do that?

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Never mind, I misread the SQL. The date is not formatted for the WHERE condition.

    WHERE (((IIf([03b-Initialize NETC Updates]![End Date]<=Now()-7,1,0))=1))

    That should work but why bother with the IIf()?

    WHERE [03b-Initialize NETC Updates]![End Date]<=Now()-7

    Don't see need for the GROUP BY - there are no aggregate calcs.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    sdc1234 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    89
    Quote Originally Posted by June7 View Post
    Never mind, I misread the SQL. The date is not formatted for the WHERE condition.

    WHERE (((IIf([03b-Initialize NETC Updates]![End Date]<=Now()-7,1,0))=1))

    That should work but why bother with the IIf()?

    WHERE [03b-Initialize NETC Updates]![End Date]<=Now()-7

    Don't see need for the GROUP BY - there are no aggregate calcs.

    Thanks, That worked...
    where can I post an excel VBA ? that I have....

    v/r
    novice

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    You want to post what?

    You can start a thread and post whatever you want. No guarantee you will get an answer.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Reports: Feilds vs Expressions
    By colleenvr in forum Reports
    Replies: 5
    Last Post: 08-13-2014, 10:35 PM
  2. Replies: 2
    Last Post: 03-04-2014, 06:46 AM
  3. Sum of Two Feilds of Two Queries in Seperate Query
    By shekar_genius in forum Queries
    Replies: 3
    Last Post: 03-13-2013, 08:27 AM
  4. Replies: 12
    Last Post: 12-14-2012, 06:25 PM
  5. Need to map excel feilds to access database ASAP (will pay $ for help)
    By Steven Thibault in forum Import/Export Data
    Replies: 22
    Last Post: 12-27-2009, 09:37 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