Formatting or displaying time

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My input is 02/04/006 00:45:09. I'm using the date/time as data type and
formatting as yyyy-mm-dd__hhmmss. It drops the first zero in the time, it
looks like this 2006-02-04__04509, it should look like this
2006-02-04__004509. I'm passing this data to another program that needs that
format.
 
Try making that first h an H. This will give leading zeros but also 23 for
11PM. Might also want to capitalize the first S.

If that doesn't help, you might need to wrap the whole thing in a CStr
function.
 
My input is from a file, that has this format 02/03/2006 00:45:45.

I used the format(table:format) of yyyy-mm-dd__hhmmss to change the layout
of the date and time.

When the time is AM and starts with a zero it is dropped, time now displays
as 5 digits, rather then 6.

The export file must have a 6 digit time format without ":", Access forces
it to 5 digits if it starts with a zero. But I need the leading zero.
 
Thanks, but I have tried the H and it still cuts the first zero off.
Not sure about the CStr function, trying to keep it simple.
 
If you are exporting the data to another application you should export the
result set of a query based on the table, not the table itself. Setting the
format property of the column in the table definition will not affect the
underlying data, only how its displayed. Date/Time values are actually
stored as a 64 bit floating point number as an offset from 30 December 1899
00:00:00.

If on the other hand you export from a query with a column formatted to your
desired format:

SELECT FORMAT(MyDateTime,"yyyy-mm-dd__hhmmss") AS MyDateTimeFormatted

the values should be returned as text in the desired format.

Ken Sheridan
Stafford, England
 
Thanks, that works great

Ken Sheridan said:
If you are exporting the data to another application you should export the
result set of a query based on the table, not the table itself. Setting the
format property of the column in the table definition will not affect the
underlying data, only how its displayed. Date/Time values are actually
stored as a 64 bit floating point number as an offset from 30 December 1899
00:00:00.

If on the other hand you export from a query with a column formatted to your
desired format:

SELECT FORMAT(MyDateTime,"yyyy-mm-dd__hhmmss") AS MyDateTimeFormatted

the values should be returned as text in the desired format.

Ken Sheridan
Stafford, England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top