473,779 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 36945
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_colum n],'dd-Mon-yyyy HH24:MI:SS')
from your_table.

All date format masks are documented; search tahiti.oracle.c om
--
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.goo glegroups.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.goo glegroups.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_FORMA T) 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
2793
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 standard for oracle. My qn is how can i pass in a date that is in DD/MM/YYYY format? This should be a common question, but i cant seem to find a working code. Can someone give me the codes please? ...
1
60935
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 automatically displayed in format, "mm/dd/yyyy" on the ASP page, but it is accepted only in another format, "dd/mon/yy". I want to make it consistent. How can I force it to accept the date in format "mm/dd/yyyy"? The second option would be to force it to...
18
10309
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 date and time, but my script is erroring. '-- Get login date and time cmdLoginDate = Date() cmdLoginTime = Time()
10
1897
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 help is appreciated in advance. While running the asp page, I still get an error as Error Type: Microsoft VBScript runtime (0x800A000D) Type mismatch: 'Format' DYNAMIC SQL STATEMENT:
5
1915
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 fix this problem ? set the user's locale / date format when program launch and reset it during exit ? Pls let me know your way to solve it. many thanks
13
3302
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 to configure server, sql server or program so it always deals with date as mm/dd/yyyy format. Thanks in advance. Roy
0
5888
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 convert the imported SAS dates into Oracle formatted dates - but I don't know if it is even possible. I'm sure it has to be...but I don't know how to go about it. I found this article: http://support.sas.com/techsup/technote/ts566d.html I'm...
3
1958
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. insert into tbl_cboss_data(mobileno,client,DATE_ACTIVATION_SWITCH,Application,TARIFF,user_name,machineip,machinetime) values('" & rs.Fields(1) & "','" & rs.Fields(2) & "','" & rs.Fields(8) & "','" & rs.Fields(9) & "', '" & rs.Fields(10) & "','" &...
6
1352
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 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
0
9632
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9471
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8958
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7478
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4036
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.