Home » SQL & PL/SQL » SQL & PL/SQL » hours validation (Oracle 10g,windows 7)
hours validation [message #600174] Fri, 01 November 2013 14:38 Go to next message
thelearner
Messages: 133
Registered: April 2013
Location: INDIA
Senior Member
I want to validate dynamic hours value using decode in sql...

If value is greater than 24PM it should display some statement...

if value is less than 0AM it should display some statment...


Please give suggestions.

[Updated on: Fri, 01 November 2013 14:46]

Report message to a moderator

Re: hours validation [message #600175 is a reply to message #600174] Fri, 01 November 2013 14:45 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
from where or how are these dynamic values obtained?
Re: hours validation [message #600176 is a reply to message #600175] Fri, 01 November 2013 14:48 Go to previous messageGo to next message
thelearner
Messages: 133
Registered: April 2013
Location: INDIA
Senior Member
actually am taking values from apex front end form....

like course calsses time 10 am to 11 AM like...

If I given greater than 24 hours it should display an error.
Re: hours validation [message #600179 is a reply to message #600174] Fri, 01 November 2013 15:06 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
thelearner wrote on Fri, 01 November 2013 15:38
I want to validate dynamic hours value using decode in sql...

If value is greater than 24PM it should display some statement...

if value is less than 0AM it should display some statment...


What is 0am and 24pm? If you use military time, there is no am and pm.

Are you looking for the difference between 2 times? It can never be more than 24 hours, unless a date is involved. If it's a date column, just subtract the first one from the second one and get the difference in days.

[Updated on: Fri, 01 November 2013 15:09]

Report message to a moderator

Re: hours validation [message #600184 is a reply to message #600179] Fri, 01 November 2013 15:19 Go to previous messageGo to next message
thelearner
Messages: 133
Registered: April 2013
Location: INDIA
Senior Member
It is a Text field. like field1: 10AM field2: 12PM

if i givn 12PM and 10AM then it should display error message
Re: hours validation [message #600187 is a reply to message #600184] Fri, 01 November 2013 15:35 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
I would use a DATE column and then you can do arithmetic against it.
Re: hours validation [message #600188 is a reply to message #600187] Fri, 01 November 2013 15:45 Go to previous messageGo to next message
thelearner
Messages: 133
Registered: April 2013
Location: INDIA
Senior Member
Little bit confused.
Re: hours validation [message #600189 is a reply to message #600188] Fri, 01 November 2013 17:42 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>if i givn 12PM and 10AM then it should display error message
little bit confused.
above is only a 10 hour duration so why should error message occur.
Re: hours validation [message #600190 is a reply to message #600189] Fri, 01 November 2013 19:19 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Just chreck if the start time is greater than the end time.
Re: hours validation [message #600193 is a reply to message #600176] Sat, 02 November 2013 01:20 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
thelearner wrote on Sat, 02 November 2013 01:18
actually am taking values from apex front end form....

like course calsses time 10 am to 11 AM like...

If I given greater than 24 hours it should display an error.


Why don't you store the complete timestamp, this will make the validation quite simple. Since you say the interval should not be > 24 hours, so you just need to check the interval between start and end time <=24 hours else throw an error. Timestamp is for compliance with ANSI.

Even if you use date datatype, the difference between start and end time in terms of days will still validate.
Re: hours validation [message #600197 is a reply to message #600193] Sat, 02 November 2013 11:29 Go to previous message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
As it is about Apex, you should create a page item validation (for example, PL/SQL function that returns error text) which would take care about valid values.
Previous Topic: deferrable initially immediate
Next Topic: Transpose and dynamic column depending on result
Goto Forum:
  


Current Time: Wed Apr 24 10:43:05 CDT 2024