Solved

Date format

Posted on 2011-09-15
3
282 Views
Last Modified: 2012-08-13
Dear Experts
I am struggling with date formatting … I am trying to create a query in VBA for a newsletter.  The Query is supposed to show all new stories since the program was last run.  The way I am trying to do this is as follows:

I have a form which has a field showing the date last run (DateLastSent), its control source is the field DateLastSent from the table DateSent.  In the table the date format is “Long Integer” & in the form the format is set to “General Date”

When I create the my query using the code below the date format swaps over from Day/Month/Year Time to Month/Day/Year Time.

How can I get this sorted out, I need to be able to use date and time in the query.

Dim SQL1str As String
SQL1str = "SELECT Posts.[Good to Go], Posts.ID, Posts.Title, Posts.Body, Posts.Published, Posts.Category.Value, Posts.[Encoded Absolute URL]From Posts WHERE (((Posts.Published)>=#" & Me.DateLastSent & "#));"
DoCmd.DeleteObject acQuery, "CopyOfDownloadNewStories"
    Dim db As DAO.Database
    Set db = CurrentDb
    db.CreateQueryDef "CopyOfDownloadNewStories", SQL1str
    Set db = Nothing

Dim SQL1str As String
SQL1str = "SELECT Posts.[Good to Go], Posts.ID, Posts.Title, Posts.Body, Posts.Published, Posts.Category.Value, Posts.[Encoded Absolute URL]From Posts WHERE (((Posts.Published)>=#" & Me.DateLastSent & "#));"
DoCmd.DeleteObject acQuery, "CopyOfDownloadNewStories"
    Dim db As DAO.Database
    Set db = CurrentDb
    db.CreateQueryDef "CopyOfDownloadNewStories", SQL1str
    Set db = Nothing

Open in new window

0
Comment
Question by:correlate
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Accepted Solution

by:
ASP8MBM earned 250 total points
ID: 36541225
0
 
LVL 77

Assisted Solution

by:peter57r
peter57r earned 250 total points
ID: 36541259
.....From Posts WHERE (((Posts.Published)>=#" & format(Me.DateLastSent,"yyyy-mm-dd") & "#));"
0
 

Author Closing Comment

by:correlate
ID: 36541287
Brilliant, thank you very much for those I  got the date bits from peter57r & the time bits from ASP8MBM
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question