Custom format of date time field

Posted on 2007-10-19
Last Modified: 2008-05-19
if i have a datetime field (in a SQL table), and I want to extract and format the date time as following, what is my syntax for doing so:

If date time is 10/19/2007 5:00:00 PM  and I want to get a string such as
"last updated on 19-Oct-2007 at 5:00 PM"
Question by:sf_garrison
    LVL 92

    Accepted Solution

    SELECT "Last updated " & Format(timestamp, "d-mmm-yyyy") & " at " & Format(timestamp, "h:mm AM/PM") AS Updated
    FROM YourTable

    Author Comment

    Excellent .. Thanks for the quick reply

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
    Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
    In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
    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…

    754 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

    24 Experts available now in Live!

    Get 1:1 Help Now