Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateOnly or Short Time formatting

Status
Not open for further replies.

BobCole

IS-IT--Management
Feb 26, 2002
8
US
I have to format a database from a community calendar for a website.

Under "Sdate," the date field, some entries are date-only. Some are date-and-time. By default, the date-only entries display as date-only, which is fine. But the date-and-time entries display with hours, minutes, seconds, and am/pm. I simply want to get rid of the "seconds" entry.

But when I tried using Format([Sdate],"mm/dd/yy"", ""hh:nn am/pm"), I got an unwanted result: the date-only entries are now displayed as "12/02/02, 12:00 am." In other words, I get "12:00 am" added to every entry that lacks a specific time.

Is there a way to display the date-only entries as date-only, while shortening the date-and-time entry to ShortDate/MediumTime?

Thanks!

-- Bob
 
If you don't need the time you can change the field to Short Date in the table design. This will drop the time off every date
 
Thanks -- I do need to keep the time when it has been included. I found out how to do it though:

SELECT IIf(TimeValue([sdate])>"12:00:00 am",Format([Sdate],"mm/dd hh:nn am/pm"),[sdate]) AS DtTm, Events.Description
FROM Events
WHERE (((Events.Description)>"0") AND ((Events.Sdate)>Now()-1));

Thanks again for your support.

-- Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top