I run this code
select to_timestamp('31-12-2006 23:34:59','DD-MM-YYYY HH24:MI:SS') from dual;
But it Displays like this
31-DEC-06 11.34.59.000000000 PM
But i expect this format
"MM/DD/YYYY HH:MI AM"
The separator should be /(slash) instead of -(hyphen).
The Second shoould not be displayed.
plz help me...
12 36891
Hi,
Try this -
-
select to_char(to_timestamp('31-12-2006 23:34:59','DD-MM-YYYY H24:MI:SS'),'MM/DD/YYYY HH12:MI AM') from dual
-
This should solve it.
Cheers
Hi,
Try this -
-
select to_char(to_timestamp('31-12-2006 23:34:59','DD-MM-YYYY H24:MI:SS'),'MM/DD/YYYY HH12:MI AM') from dual
-
This should solve it.
Cheers
Fine... This is worked as i expected, but the field should not be converted to string. Because further i have to sort that field. If it is converted to string i can't sort that field. Because it consists AM and PM field.
plz reply what i need..
replace this by previous query -
select to_char(to_timestamp('31-12-2006 23:34:59','DD-MM-YYYY HH24:MI:SS'),'MM/DD/YYYY HH12:MI AM') from dual
-
only add HH24 in place of H24
Ok Fine... This is worked as i expected, but the field should not be converted to string. Because further i have to sort that field. If it is converted to string i can't sort that field. Because it consists AM and PM field.
plz reply what i need..
Hi,
You can store the value of date in the default Oracle format itself. So it would be possible for sorting. You can use the to_char function to change the format of the date to what you want when ever you are displaying.
Would this solve your problem?
Cheers
Thanks for ur reply...
My table oracle table format is
order_entry_date ---- date
order_entry_time ---- varchar2(10)
My client expects to concat these two fields and then sort that concatinated field. If i concat these two fields it is changed as string. then When i sort that field, it does not bother about AM and PM. It only sorts Date and Time.. it did not bother AM and PM..
thanks...
Hi,
I think if you have the concatenated field as YYYY/MM/DD HH12:MI AM/PM
It would sort correctly.
Cheers
Hi,
No. If the concatenated field is String, it is not sorted correctly. Only sorted, when it is timestamp field.
If it is String, it looks like this after sorting,
01-JAN-07 01.00 AM
01-JAN-07 02.00 PM
01-JAN-07 03.00 AM
01-JAN-07 04.00 AM
But It should be
01-JAN-07 01.00 AM
01-JAN-07 03.00 AM
01-JAN-07 04.00 AM
01-JAN-07 02.00 PM
See Am and Pm closely....
Hi,
If you store the concatenated field as YYYY/MM/DD HH12:MI AM/PM
Then you can sort using
(assume concatenated field is dt)
Select dt from table order by substr(dt,1,10),substr(dt,length(dt)-2,length(dt)),substr(dt,11,5)
The first substring is for date, second for am/pm and third for time.
Would this help?
Cheers
Hi,
If you still want it in MM/DD/YYYY HH12:MI AM/PM format then you can change the order by clause as
(assume dt is the concatenated field) -
select dt from table
-
order by substr(dt,7,4),substr(dt,1,2),substr(dt,4,5),substr(dt,length(dt)-1,2),substr(dt,11,7) asc
-
first substring selects year,the second month,third day, fourth am/pm and fifth for time
Cheers
Hi,
Thanks for ur reply..
your concept is nice...
but sometime i have null value in time column... so i cant use it..
Now it is worked as i expect. But i used someother way..
What i did is
1. I concated DATE and TIME Column
2. Then I converted into TIMESTAMP type.
3. Then I sorted that TIMESTAMP column
4. Then by using String function I display what I need.
bye...
[quote=rsrinivasan;2552332]Hi,
Thanks for ur reply..
what string function you have used at the end ....???
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Riley |
last post by:
The date fields being saved by a VB program were being saved
as #2003-11-22#. For reasons unknown to me these dates began
to be saved as "11/22/2003"
All of these dates were made dates with the...
|
by: Alistair |
last post by:
diary_date = request.form("diary_date") - (from a populated drop down
list)
strSQL = "SELECT saz_title, saz_text from saz_details where saz_date =#" &
diary_date & "#"
a response.write...
|
by: PW |
last post by:
<rant>
Sorry guys, but I just have to whinge. Dates in ASP are a total pain in the
butt! I seem to get caught out so many times. I realise its my own fault,
but going from the posts in this...
|
by: Colin Steadman |
last post by:
I'm a stupid ASP programmer and I dont do Javascript (except for very
simple tasks anyway), and I'm in a bit of a predicament. I've used a
javascript table sorting script from here:
...
|
by: Bambero |
last post by:
Hello all
Problem like in subject. There is no problem when I want to count days
between two dates. Problem is when I want to count years becouse of
leap years.
For ex.
between
2002-11-19...
|
by: kaab kaoutar |
last post by:
Hi,
A client is using postgresql 7.1.3, and to_date() and to_timestamp()
functions fail sometimes,However they never do in postgresql 7.3.2.
Are these bugs?
Thx
...
|
by: Dixie |
last post by:
I am trying to calculate the number of workdays between two dates with
regards to holidays as well. I have used Arvin Meyer's code on the Access
Web, but as I am in Australia and my date format is...
|
by: pitfour.ferguson |
last post by:
My dbase has the start date and end date of each visit. How can I ask
Access to list the day of the week of the start (easy), end (easy) and,
more importantly, the dates of the visit itself - ie...
|
by: Jim Carlock |
last post by:
(1) Does PHP provide any way to handle dates prior to 1980?
I know there's problems with Microsoft Windows NT and all Windows
NT operating systems will allow a date prior to 1980 to be placed...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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...
| |