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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display date using dashes and military time without colon using format now() Function 1

Status
Not open for further replies.

iojbr

Technical User
Feb 12, 2003
129
US
Hi:

I am trying to use the format now function to display date and time in a Access table in this format: MM-DD-YYYY HHnn(military time)

Tried to do this (see below) but it doesn't

X = Format(now(),"MM-DD-YYYY HHnnss")

Any help is appreciated. Thanks.
 
Hi,

The "format" makes no difference in a table.

You can FORMAT your display in a query, on a form or in a report.
 
Try:
[tt]Debug.Print Format(Now, "mm/dd/yyyy [blue]hh:nn[/blue]")[/tt]

Example from here

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Thanks for your help. I wanted to clarify that what I am doing is importing a .csv file into a database table, and then updating a column (called "current date and time stamp") via update statement using VBA code.

S7 = "Update [Assay Mix Replicates_Temp] Set [Date/Time Stamp] = '" & Format(Now(), HHnnss) & "'"
DoCmd.RunSQL S7

 
S7 = "Update [Assay Mix Replicates_Temp] Set [Date/Time Stamp] = '" & Format(Now(), [!]"[/!]HHnnss[!]"[/!]) & "'"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
A date/time is stored aa a number in your table without regard to display format.
 
Wouldn't that be:

S7 = "Update [Assay Mix Replicates_Temp] Set [Date/Time Stamp] = [red]#[/red]" & Format(Now(), "HHnnss") & "[red]#[/red]"

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Thanks for the help.

I changed the original update statement to:

S7 = "Update [Assay Mix Replicates_Temp] Set [Date/Time Stamp] = '" & Cstr(Format(Now(), "MM-DD-YY HHnn")) & "'" and changed the datatype for the [Date/Time Stamp] field from Date to text. Everything is working now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top