now() format question

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

Guest

to get a unique identifier i use the now() function and on the form it
displays like this "2007-02-26T11:46:57" but uses a 24 hour clock

is there a way to change the format?


i was trying to get auto numbering to work but even with a access database
it still wouldn't increment. every form had the same number.

thanks,
 
The format would be:

yyyy-mm-dd hh:nn:ss AM/PM

I have no idea what the "T" is in your example. Also, I've never seen an
autonumber not work. Obviously, you haven't put a unique index on the field
because it is impossible to have a duplicate that is unique.
 
How do you want to display the value returned by Now()?

Did you mean the JET AutoNumber Field?

Check the Field Data Type and Size and the Property "New Values" of the
Field in the Table Design view. They should be:

Data Type: AutoNumber
Field Size: Long Integer
New Values: Increment
 
Ah. I see. Thanks.

So the answer is: There is no built in way to format the date/time as ISO
8601, but if one wanted to write some code, they could store it that way as
a text datatype, then for calculations, parse and convert it back to a
double or date/time datatype. Unless there's a specific requirement to do
so, I wouldn't bother.
 
There is no built in way to format the date/time as ISO
8601, but if one wanted to write some code, they could store it that way as
a text datatype

That would be an extreme reaction IMO: strong data typing is a good
thing, formatting should be performed external to the database and the
format/unformat operations aren't too involved e.g.

Format$(Now, "yyyy-mm-ddThh:nn:ss")

CDate(Replace$("2007-02-28T08:05:42", "T", " "))

Jamie.

--
 

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