473,401 Members | 2,146 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,401 software developers and data experts.

format date with Oracle Dynamic SQL

Hi all,

when i set a date field's type (12) to VARCHAR2 or STRING, I get the
date (mm/dd/yyyy) correct, but I can never get the time which is always
set to 00:00:00 even if i increase the buffer size? Is there anyway to
force pro*c to format correctly without using to_char because with
to_char i lose the ability to keep track of correct data type.

Thanks

Jul 19 '05 #1
6 36889
de************@gmail.com wrote:
Hi all,

when i set a date field's type (12) to VARCHAR2 or STRING, I get the
date (mm/dd/yyyy) correct, but I can never get the time which is always
set to 00:00:00 even if i increase the buffer size? Is there anyway to
force pro*c to format correctly without using to_char because with
to_char i lose the ability to keep track of correct data type.

Thanks


Dates are stored internally as numbers, and always
include a time fraction.

The display (or format) mask is what makes it visible
as a date - but you must specify it.
What you experience is the default date format, try
to select to_char([your_date_column],'dd-Mon-yyyy HH24:MI:SS')
from your_table.

All date format masks are documented; search tahiti.oracle.com
--
Regards,
Frank van Bortel
Jul 19 '05 #2
we are dynamically retrieving data types of a dynamic query and build
an XML resultset. to_char i believe gives us a string type when we
wanted a date type for that field. Is there a way to do it?

Jul 19 '05 #3
de************@gmail.com wrote:
we are dynamically retrieving data types of a dynamic query and build
an XML resultset. to_char i believe gives us a string type when we
wanted a date type for that field. Is there a way to do it?

to_date(string, format_mask)

What other documentation shall I read you?

--
Regards,
Frank van Bortel
Jul 19 '05 #4
sorry about bothering you, but when i do something like

select to_date(to_char(date_column, 'yyyy-mm-dd hh24:mi:ss'),
'yyyy-mm-dd hh24:mi:ss') from table_name

in my pro*c code, i get back

2005-02-24 00:00:00

when data is 2005-02-24 11:05:07

Jul 19 '05 #5

<de************@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
sorry about bothering you, but when i do something like

select to_date(to_char(date_column, 'yyyy-mm-dd hh24:mi:ss'),
'yyyy-mm-dd hh24:mi:ss') from table_name

in my pro*c code, i get back

2005-02-24 00:00:00

when data is 2005-02-24 11:05:07
get rid of the to_date. Doesn't ProC have a native date interface?
Wouldn't it make more sence to use that?
Jim

Jul 19 '05 #6

<de************@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
sorry about bothering you, but when i do something like

select to_date(to_char(date_column, 'yyyy-mm-dd hh24:mi:ss'),
'yyyy-mm-dd hh24:mi:ss') from table_name

in my pro*c code, i get back

2005-02-24 00:00:00

when data is 2005-02-24 11:05:07


the TO_DATE is using the default date format (NLS_DATE_FORMAT) to convert
back to a date column -- that is likely truncating the time element

if you want a date, don't use either to_date or to_char

if you need to convert to or from a date datatype, us to_date or to_char
(seldom are both ever used together) with the appropirate date format -- or
use ALTER SESSION to set the default date format for your session

++ mcs
Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: chelleybabyger | last post by:
my database, sqlplus oracle, has a column ccexpiry, whch is set to date. In my form in asp, there will always be an error whenever i pass in a date that is not in the DD MMM YYYY which is the...
1
by: jt | last post by:
I posted this yesterday, but I am not seeing this out yet: I am having problems with updating a date field in a certain format. The data is stored in an Oracle database. The date is...
18
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the...
10
by: Jack | last post by:
Hi, I cannot get the date format correctly in dynamic sql statement, after trying various ways of handling it. I need some help with the date format in the following dynamic sql statement. Any...
5
by: jeff | last post by:
i have written a program with date format as m/d/yyyy when i deploy it to client's machine, due to the client use d/m/yyyy format the Select SQL statement return some record wrongly. how can i...
13
by: Roy | last post by:
Hi all, I'm creating a project that should always use this date format when displays the dates or create dates. The back end database is a SQL Server and I like to know what is the logical way...
0
by: Jaye | last post by:
Hi. I was wondering if anyone knows how to convert dates in the SAS format into an Oracle date format without the use of third party software. I'd like to be able to run a procedure that would...
3
by: puruji | last post by:
while importing date field from excel to oracle using VB6 i got a problem in date format....they do no match...in excel it gives date in format mm/dd/yy but in oracle i need dd-mm-yyyy so? to do....
6
by: deadlocklegend | last post by:
Hi all, when i set a date field's type (12) to VARCHAR2 or STRING, I get the date (mm/dd/yyyy) correct, but I can never get the time which is always set to 00:00:00 even if i increase the buffer...
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: 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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.