Subject | Re: [firebird-support] Re: Date, Time, TimeStamp Format/Separator ... |
---|---|
Author | Theo Bebekis |
Post date | 2004-04-15T12:48:40Z |
Dimitris
most of the db systems understand ISO date time strings (ISO 8601).
Firebird is not an exception.
So regardless of the system settings (date time format, separators etc)
you can use the below format.
YYYY-MM-DD hh:nn:ss.zzz
Here are two functions I use with Delphi
(*--------------------------------------------------------------------------------*)
function DateTimeToStrSQL(ADateTime: TDateTime; bQuoted : boolean): string;
begin
Result := FormatDateTime('yyyy-mm-dd hh:nn', ADateTime);
if bQuoted then Result := Format('''%s''', [Result]);
end;
(*--------------------------------------------------------------------------------*)
function TimeStamp(ADateTime: TDateTime; bQuoted : boolean): string;
begin
Result := FormatDateTime('yyyy-mm-dd hh:nn:ss', ADateTime);
if bQuoted then Result := Format('''%s''', [Result]);
end;
Theo
PS. check the relevant W3C technical report at
http://www.w3.org/TR/NOTE-datetime
-----------------------------------------------
Theo Bebekis
Thessaloniki, Greece
-----------------------------------------------
Greek_Delphi_Prog
a Delphi programming list in greek language at
http://groups.yahoo.com/group/Greek_Delphi_Prog
-----------------------------------------------
most of the db systems understand ISO date time strings (ISO 8601).
Firebird is not an exception.
So regardless of the system settings (date time format, separators etc)
you can use the below format.
YYYY-MM-DD hh:nn:ss.zzz
Here are two functions I use with Delphi
(*--------------------------------------------------------------------------------*)
function DateTimeToStrSQL(ADateTime: TDateTime; bQuoted : boolean): string;
begin
Result := FormatDateTime('yyyy-mm-dd hh:nn', ADateTime);
if bQuoted then Result := Format('''%s''', [Result]);
end;
(*--------------------------------------------------------------------------------*)
function TimeStamp(ADateTime: TDateTime; bQuoted : boolean): string;
begin
Result := FormatDateTime('yyyy-mm-dd hh:nn:ss', ADateTime);
if bQuoted then Result := Format('''%s''', [Result]);
end;
Theo
PS. check the relevant W3C technical report at
http://www.w3.org/TR/NOTE-datetime
-----------------------------------------------
Theo Bebekis
Thessaloniki, Greece
-----------------------------------------------
Greek_Delphi_Prog
a Delphi programming list in greek language at
http://groups.yahoo.com/group/Greek_Delphi_Prog
-----------------------------------------------
----- Original Message -----
From: "Martijn Tonies" <m.tonies@...>
To: <firebird-support@yahoogroups.com>
Sent: Thursday, April 15, 2004 12:31 PM
Subject: Re: [firebird-support] Re: Date, Time, TimeStamp Format/Separator ...
> Hi,
>
> > > > how can i get the active date, time, timestamp format and
> > > > separator with sql ?
> > > >
> > > > i.e. dd/mm/yyyy or mm/dd/yyyy with separator '/'
> > > > or mm.dd.yyyy with separator '.' etc
> > >
> > > SELECT CURRENT_TIMESTAMP, CURRENT_TIME,
> > > CURRENT_DATE
> > >
> > > FROM RDB$DATABASE
> > >
> > > The separator is a client side display thingy.
> >
> > Maybe i wasn't clear enough :)
> >
> > I want to construct a sql query through code ( Delphi ). But
> > because the client's are in varius locales (Greek, English,
> > Bulgarian, Romanian ) different from the server locale i need a
> > universal way of constructing the date field or the time field or
> > the timestamp. Else i get an error message ... You
> > know '...transliterate blablabla ...'.
>
> Ah, ok :-) ...
>
> Well, there are several ways to do this - probably the easiest
> is to use parameters for your date/time/datetime values:
>
> WHERE ... = :MyDateTimeParam
>
> This way, you don't have to bother about locales.
>
> Alternatively, use the English style:
>
> WHERE ... = 'mm/dd/yyyy'
>
> With regards,
>
> Martijn Tonies
> Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
> Server.
> Upscene Productions
> http://www.upscene.com
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>