Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date format when casting as varchar [CORE1341] #1760

Closed
firebird-automations opened this issue Jul 3, 2007 · 13 comments
Closed

Date format when casting as varchar [CORE1341] #1760

firebird-automations opened this issue Jul 3, 2007 · 13 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: ramengo (ramengo)

Duplicates CORE1314

Votes: 4

It would be useful to have a built-in function which formats date when casting as varchar.
For example, the following select:
select cast(current_date as varchar(30))
from RDB$Database
would return:
2007-07-03
while I need different formats like:
03-jul-2007 or 03/07/2007

Same story with timestamp but with time format indication...

@firebird-automations
Copy link
Collaborator Author

Commented by: ramengo (ramengo)

I was thinking to "to_char" command in Oracle, where you can do:
select to_char(sysdate, 'dd-mon-yyyy') from dual
obtaining:
'09-aug-2007'

Is it possible to have a similar behaviour in FB ?

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

I would prefer a generic FORMAT function, but this requires we return strings of unknown (at prepare time) length, and we don't support this yet.

@firebird-automations
Copy link
Collaborator Author

Commented by: ramengo (ramengo)

I see.
BTW, the "format" function would be good for numeric columns too (eg: formatting number with different decimal separator from "."). Actually I have to use replace of cast...
Hope the limitation of unknown length string will be resolved soon !
Keep up the good work guys.

@firebird-automations
Copy link
Collaborator Author

Commented by: ramengo (ramengo)

Hey, I just want to follow the invite of the Firebird homepage: "Is there a feature you would like to request?"... hehehe
Well, could this "format" functionality be added to the next FB release ?
Thanks in advance !

@firebird-automations
Copy link
Collaborator Author

Commented by: Mustafa Simsek (mussimsek)

Hi,

i vote for generic Format date-time funciton too.

FormatDateTime (format_string, date-time value) = formatted string

format_string could be general for other db & languages.

d - day(1-31)
dd - day (01-31)
m - month (1-12)
mm - month (01-12)
mmm (short month name : Jan-Feb...)
mmmm (month name : January...)
yy (year, two digit : 08)
yyyy (year, four digit : 2008)
etc.

Best Regards.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Workflow: jira [ 12490 ] => Firebird [ 14899 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: Andre Litfin (andrelitfin)

What about this function? Will this function be integrated in FB 2.5?? At the moment I'm using an UDF, but it's better when it's integrated...

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-automations
Copy link
Collaborator Author

Commented by: ramengo (ramengo)

Hi,

if you implement this functionality into 2.5, then don't forget another similar to format numers.
In Oracle there is to_char which formats dates and numbers.

Example 1:
to_char(current_date, 'dd-mon-yyyy') returns 12-may-2008

Example 2:
to_char(123456.1, '999G999D00') returns 123,456.10

See http://www.dba-oracle.com/f_to_char_sql.htm
TIA.

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

I'm marking this as duplicate because it's better to have a unified format routine, as in CORE1314.

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Duplicate [ 3 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

Link: This issue duplicates CORE1314 [ CORE1314 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants