[AccessD] Datepart 24 hours

Gustav Brock Gustav at cactus.dk
Mon Jan 29 04:41:43 CST 2007


Hi Mark

Sorry, I had something else in mind ... 

If you wish AM/PM spelled out, use Format:

  strHours = Format(t, "h AM/PM")

If you wish the hour number, Bill's method should read like this:
  intHours = IIf(DatePart("h", t) > 12, DatePart("h", t - 12 / 24), DatePart("h", t))
or:
  intHours = IIf(Hour(t) > 12, Hour(t) - 12, Hour(t))

A fancy method is:
  intHours = Val(Format(t, "h AM/PM"))

or you could use simple math:
  intHours = (Hour(t) - 1) Mod 12 + 1

/gustav

>>> markamatte at hotmail.com 29-01-2007 05:29:28 >>>
Hello All,

In using DatePart("h",[ArrestDT]) I get the 24 hour clock...is there a 
variation of this formula to get a 12 hour clock...or do I need if 
statements to calculate when over 12 and account for 00?

Thanks,

Mark A. Matte




More information about the AccessD mailing list