Hey all,

I'm trying to parse an hour, minute, and meridian entered on a webform
as time.

So...three combo boxes. One from 00 to 12 , the other from 0 to 55..and
then the last with AM|PM.

I then create a date like this:

        <cfset MyTimeValue =
CreateDateTime(Year(arguments.TheDate),Month(TheDate),Day(TheDate),(TheH
our),TheMinute,00)>
Of course..this works when the Meridian is AM...

But when the meridian is PM..we need to add 12 to the time don't we?
Since the ODBC time runs on a 24Hour clock.

(We don't want our users having to think for a 24 hour clock
though...hence the combo boxes).

However...when 12:00 PM is selected....adding 12 would result in 24:00.
Which is invalid...
It should be 0000 hours.

So here is the code I ended up with:
                
                <cfif Arguments.AMPM eq "AM">
                
                        <cfset MyTimeValue =
CreateDateTime(Year(arguments.TheDate),Month(TheDate),Day(TheDate),TheHo
ur,TheMinute,00)>
                
                <cfelse>
                
                        <CFSET ARGUMENTS.TheHour = TheHour + 12>
                        <CFIF TheHour EQ 24>
                                
                                <CFSET Arguments.TheHour = 0>
                        
                        </CFIF>
                        <cfset MyTimeValue =
CreateDateTime(Year(arguments.TheDate),Month(TheDate),Day(TheDate),(TheH
our),TheMinute,00)>
                </cfif> 

Somehow though..this just seems so very inelegant. And I'm wondering if
I am doing something completely wrong...or if anyone knows a better way
to do it.

-Angel




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to