Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Date format

Posted on 2011-09-15
3
Medium Priority
?
288 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 1000 total points
ID: 36541225
0
 
LVL 77

Assisted Solution

by:peter57r
peter57r earned 1000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

636 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