|
INTERVIEW QUESTIONS
DATABASE
FIREBIRD
DETAILS
Question: How do convert or display the date or time as string?
Answer: Simply 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;
|
|
|
Category |
Firebird Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 8397 users |
Added on |
7/23/2015 |
Views |
69964 |
Rate it! |
|
|
Question:
How do convert or display the date or time as string?
Answer:
Simply 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; Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
How to configure events with firewall?
|
View Answer
|
|
How to change database dialect?
|
View Answer
|
|
How to add, remove, modify users using SQL?
|
View Answer
|
|
How to activate all indexes in Firebird?
|
View Answer
|
|
Can I concurrently access a Firebird database with embedded and with regular server?
|
View Answer
|
|
What is command for supporting foreign key in Firebird?
|
View Answer
|
|
What is the maximum number of rows in a table in Firebird?
|
View Answer
|
|
What are the vital features of Firebird that makes it powerful database?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All Firebird Interview Questions & Answers - Exam Mode /
Learning Mode
|