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
Solved

Date format

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
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…

839 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