How can I convert a char to date? [message #110975] |
Fri, 11 March 2005 10:54 |
ipq2418
Messages: 1 Registered: March 2005
|
Junior Member |
|
|
Hi!
I am developing an aplication with SQL Embeded and I am having some problems with it:
I have a variable whose type is char and I want to make an insert statement with it but when I execute it the date inserted is 00/00/0000.
Here is the code:
.
.
EXEC SQL BEGIN DECLARE SECTION;
CHAR DATEJOUR[9];
EXEC SQL END DECLARE SECTION;
(I inicialize the variable with a date with format 'DD/MM/YY' ended with '\0')
EXEC SQL INSERT INTO hrb (hrb,REBUT,NO_OF,INDICE_OF,OPERATION,MACHINE,POSTE,COMPAGNON,QTE_REBUT,DATE_CONSTAT) DATE_CONSTAT (:no_ordre,:no_ordre,:cle_ofc.of,:cle_ofc.indice,:indice,:ope_suiv,'0',:compagnon,:compagnon,:poids);
How I could make the conversion between types?
Thanks:)
IPQ";)
[Updated on: Fri, 11 March 2005 10:56] Report message to a moderator
|
|
|
|
|
|
Re: How can I convert a char to date? [message #112745 is a reply to message #112688] |
Tue, 29 March 2005 01:13 |
|
Maaher
Messages: 7065 Registered: December 2001
|
Senior Member |
|
|
Michael, I don't agree at all! The default date format is depending on X factors (both server as client have their influence on this). I've been trying to convince end users and forum members that date manipulation in Oracle should always go through proper casting (it's the only way to be sure that date handling goes well).
Michael Hartley | For input and output of dates, the standard Oracle default date format is DD-MON-RR. For example:
'13-NOV-1992'
|
What is it? 'DD-MON-RR' or 'DD-MON-YYYY' or (like at our shop) 'DD-MON-YY'? See my point?
[EDIT: typo]
MHE
[Updated on: Tue, 29 March 2005 01:14] Report message to a moderator
|
|
|
|
Re: How can I convert a char to date? [message #112761 is a reply to message #112759] |
Tue, 29 March 2005 03:35 |
|
Maaher
Messages: 7065 Registered: December 2001
|
Senior Member |
|
|
Clearly you didn't see my point then...oh well:
I just wanted to make it clear that implicit casting is not a good idea. That's all.
Quote: | The fact your local site does not use the default date format has no influence on the out of the box default date format.
| Euhr...you are convinced that the entire world is part of the United Kingdom? NLS_TERRITORY specifies the implicit default date format (what you were referring to I guess). And for UK it is, indeed (drum roll ), 'DD-MON-RR'. But our local site is just another example of the real world, with its own defaults.
No offence, but there are other territories (even out the box).
PS: I don't want to start an entire discussion on territories or whatever, I'm just stating that explicit casting is the way to go.
[EDIT: Read the manual, it's stated nowhere that the default date format is set to 'DD-MON-RR', at least not in the online docs.]
[EDIT2: Yes it does, see followup ]
MHE
[Updated on: Tue, 29 March 2005 04:51] Report message to a moderator
|
|
|
|
|