Solved

Date format

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now