Subject | Re: [firebird-support] how to insert DATE in a different format? |
---|---|
Author | Ceyhun Atacan |
Post date | 2005-06-30T07:19:05Z |
Thanks Helen, that explains it very well.
The reason I was asking is that in a Windows Forms
application the datetimepicker control returns the
date selected as a string in the dd/mm/yyyy format. I
was hoping to pass this value directly down to my data
access layer without any modifications. But realizing
that a datetimepicker control returns locale dependant
literals, I now think it wouldn't be a good idea
anyway.
Just out of curiosity, is there any document that
lists the legitimate literals that can be used for FB
DATEs? Or is there a numerical representation of DATEs
that can be used across different databases? A value
that I could compute in the application and pass to
whichever database I'm using? (assuming I could work
with numerical values for DATEs in my interaction with
the database, otherwise this would be irrelevant)
Thanks again.
--- Helen Borrie <helebor@...> wrote:
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
The reason I was asking is that in a Windows Forms
application the datetimepicker control returns the
date selected as a string in the dd/mm/yyyy format. I
was hoping to pass this value directly down to my data
access layer without any modifications. But realizing
that a datetimepicker control returns locale dependant
literals, I now think it wouldn't be a good idea
anyway.
Just out of curiosity, is there any document that
lists the legitimate literals that can be used for FB
DATEs? Or is there a numerical representation of DATEs
that can be used across different databases? A value
that I could compute in the application and pass to
whichever database I'm using? (assuming I could work
with numerical values for DATEs in my interaction with
the database, otherwise this would be irrelevant)
Thanks again.
--- Helen Borrie <helebor@...> wrote:
> At 05:57 AM 30/06/2005 +0000, you wrote:__________________________________________________
> >I'd like to insert a date into a DATE column in the
> dd/mm/yyyy format
> >but FB expects it in the mm/dd/yyyy format. (I get
> a "convertion error
> >from string '15/01/2005'" when I try the INSERT
> INTO TBL VALUES
> >('15/01/2005') statement. (TBL is a table with only
> one column of type
> >DATE).
> >
> >Interestingly when I retrieve dates which were
> inserted in the expected
> >format (i.e. mm/dd/yyyy), they seem to be stored in
> the format I want
> >(i.e. IBExpert displays them in the dd/mm/yyyy
> format)
> >
> >Anyway, I'm just curious if there is an easy way to
> change the format
> >FB accepts date values?
> >
> >I'm using FB embedded 1.5.2. I'm new to FB and SQL
> so I'd appreciate
> >any help. Thanks!
>
> In fact, Firebird doesn't store "formatted"
> date/time types at all. It
> stores them in a numeric format. When you offer a
> string as input to a
> date/time type, what you are really offering is a
> date literal. As long as
> the parser can make sense of the format of the
> literal, it can convert this
> literal to a date/time type and store it correctly.
> The reverse process -
> the string that gets returned when the Firebird
> engine retrieves date/time
> types is not a question of "inverting" the inward
> process.
>
> A literal in the format 'dd/mm/ccyy' or 'dd/mm/yy'
> is NOT one that Firebird
> interprets as a valid date. With a slash separator,
> only 'mm/dd/ccyy' or
> 'mm/dd/yy' is valid. Hence, your example would mean
> "the first day of the
> 15th month" so it is rejected as invalid.
> '9/01/2005' would be interpreted
> as "September 1st".
>
> We who operate beyond the shores of the United
> States use 'dd.mm.ccyy',
> 'ccyymmdd', 'ccyy-mm-dd' or 'dd-MMM-ccyy' mostly.
> Some other formats are
> acceptable - but formats that include slashes are
> not among them.
>
> ./heLen
>
>
>
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com