[AccessD] Datepart 24 hours

Mark A Matte markamatte at hotmail.com
Mon Jan 29 09:53:54 CST 2007


Hello All,

Thanks for all of the suggestions.  Alot of the suggestions were 
similar...(using if>12 then -12...)

None of these took into account that the functions DATEPART and HOUR would 
return 0 for 12:00 AM...not 24...

These are the 2 suggestions that gave me what I needed(1-12).

  intHours = Val(Format(t, "h AM/PM"))
  intHours = Format(t, "h AM/PM")

Thanks Again,

Mark A. Matte


>From: "Gustav Brock" <Gustav at cactus.dk>
>Reply-To: Access Developers discussion and problem 
>solving<accessd at databaseadvisors.com>
>To: <accessd at databaseadvisors.com>
>Subject: Re: [AccessD] Datepart 24 hours
>Date: Mon, 29 Jan 2007 11:41:43 +0100
>
>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
>
>--
>AccessD mailing list
>AccessD at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/accessd
>Website: http://www.databaseadvisors.com

_________________________________________________________________
Laugh, share and connect with Windows Live Messenger 
http://clk.atdmt.com/MSN/go/msnnkwme0020000001msn/direct/01/?href=http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=hmtagline




More information about the AccessD mailing list