How do convert or display the date or time as string?
Submitted by: AdministratorSimply use CAST to appropriate CHAR or VARCHAR data type (big enough). Example:
CREATE TABLE t1 ( t time, d date, ts timestamp );
INSERT INTO t1 (t,d,ts) VALUES ('14:59:23', '2007-12-31', '2007-12-31 14:59');
SELECT CAST(t as varchar(13)), CAST(d as varchar(10)), CAST(ts as varchar(24))
FROM t1;
Firebird would output times in HH:MM:SS.mmmm format (hours, minutes, seconds, milliseconds), and dates in YYYY-MM-DD (year, month, day) format.
If you wish a different formatting you can either use SUBSTRING to extract the info from char column, or use EXTRACT to buld a different string:
SELECT extract(day from d)||'.'||extract(month from d)||'.'||extract(year from d)
FROM t1;
Submitted by: Administrator
CREATE TABLE t1 ( t time, d date, ts timestamp );
INSERT INTO t1 (t,d,ts) VALUES ('14:59:23', '2007-12-31', '2007-12-31 14:59');
SELECT CAST(t as varchar(13)), CAST(d as varchar(10)), CAST(ts as varchar(24))
FROM t1;
Firebird would output times in HH:MM:SS.mmmm format (hours, minutes, seconds, milliseconds), and dates in YYYY-MM-DD (year, month, day) format.
If you wish a different formatting you can either use SUBSTRING to extract the info from char column, or use EXTRACT to buld a different string:
SELECT extract(day from d)||'.'||extract(month from d)||'.'||extract(year from d)
FROM t1;
Submitted by: Administrator
Read Online Firebird Job Interview Questions And Answers
Top Firebird Questions
☺ | How to detect the server version? |
☺ | How to write UDF s in Delphi? |
☺ | How do convert or display the date or time as string? |
☺ | How to drop all foreign keys in database? |
☺ | Is there some bulk load or other way to import a lot of data fast? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |
☺ | Sybase Interview Questions. |