Solved

Date format

Posted on 2011-09-15
3
278 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
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
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…

831 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