473,396 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Time Function

Hi friends,
I need to round or truncate the time.. If 1:24 means i need 1 clock
1:32 means i need 2 clock ... suppose the time in 11:45 PM i need 12:00 am
and the time in 11:45 am i need 12:00 pm.. the time should be 12 hours format


i write a query in 24 hours

SELECT (CASE WHEN SUBSTR(TO_CHAR(SYSDATE,'HH24:MI'),4,5) >=30 THEN
SUBSTR(TO_CHAR(SYSDATE,'HH24:MI'),1,2)+1
ELSE TO_NUMBER(SUBSTR(TO_CHAR(SYSDATE,'HH24'),1,2)) END) AS DATEE
FROM DUAL;


it works perfectly because this is a 24 hours format... i need 12 hours
Sep 6 '07 #1
1 1786
amitpatel66
2,367 Expert 2GB
Hi friends,
I need to round or truncate the time.. If 1:24 means i need 1 clock
1:32 means i need 2 clock ... suppose the time in 11:45 PM i need 12:00 am
and the time in 11:45 am i need 12:00 pm.. the time should be 12 hours format


i write a query in 24 hours

SELECT (CASE WHEN SUBSTR(TO_CHAR(SYSDATE,'HH24:MI'),4,5) >=30 THEN
SUBSTR(TO_CHAR(SYSDATE,'HH24:MI'),1,2)+1
ELSE TO_NUMBER(SUBSTR(TO_CHAR(SYSDATE,'HH24'),1,2)) END) AS DATEE
FROM DUAL;


it works perfectly because this is a 24 hours format... i need 12 hours
Replace 24 with 12:

SELECT (CASE WHEN SUBSTR(TO_CHAR(SYSDATE,'HH12:MI'),4,5) >=30 THEN
SUBSTR(TO_CHAR(SYSDATE,'HH12:MI'),1,2)+1
ELSE TO_NUMBER(SUBSTR(TO_CHAR(SYSDATE,'HH12'),1,2)) END) AS DATEE
FROM DUAL
Sep 6 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
6
by: David Graham | last post by:
Hi I have asked this question in alt.php as the time() function as used in setcookie belongs to php - or does it belong equally in the javascript camp - bit confused about that. Anyway, can anyone...
17
by: newbiecpp | last post by:
I have hard time to understand run-time environment. Let assume that I have a program that has a simple variable alpha. When this variable is statically allocated, the compiler can use the...
17
by: Razzel | last post by:
I created this as a test: #include <time.h> main(){ printf(X1: %s\n", putim()); printf(X2: %s\n", putim()); } putim() { time_t t; time(&t); return(ctime(&t));
5
by: Sinan Nalkaya | last post by:
hello, i need a function like that, wait 5 seconds: (during wait) do the function but function waits for keyboard input so if you dont enter any it waits forever. i tried time.sleep() but when...
3
by: cj | last post by:
If I want to check to see if it's after "11:36 pm" what would I write? I'm sure it's easy but I'm getting tired of having to work with dates and times. Sometimes I just want time or date. And...
6
by: Luvin lunch | last post by:
Hi, I'm new to access and am very wary of dates as I have limited experience in their manipulation and I know if they're not done properly things can turn ugly quickly. I would like to use a...
9
by: Ron Adam | last post by:
I'm having some cross platform issues with timing loops. It seems time.time is better for some computers/platforms and time.clock others, but it's not always clear which, so I came up with the...
0
yasirmturk
by: yasirmturk | last post by:
Standard Date and Time Functions The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any...
1
by: nigelesquire | last post by:
I am in need of your assistance. I have a page with multiple unixtime stamps and I need to display them in readable time and date with the user's time zone. Below is the code. <!DOCTYPE...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.