Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date formatting form Oracle to asp

Status
Not open for further replies.

malaygal

IS-IT--Management
Feb 22, 2006
192
US
I have a date field on my asp page that is coming from an Oracle database table.
Field shows: 20070515132054, how can I format it on the asp page to show 05/15/2007.

Any help will be greatly appreciated.
 
Hi,
Date types in Oracle are stored as a specially formatted number, as you have discovered..Assuming the driver you are using to connect to Oracle can handle it, use the To_Char function in your query string to format the Date as needed...

"Select to_char(DateFieldinOracle,'MM/DD/YYYY'),etc..."

Note..It is now a string value so it would need to be reconverted to a recognized Date ( in VB or C#, whatever) if you want to use date math or other actual DATE related actions later in your code..



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
It's been awhile since my HOracle days, but another suggestion.

To_Date(to_char(DateFieldinOracle,'MM/DD/YYYY')) or it's
To_Date(to_char(DateFieldinOracle,'MM/DD/YYYY'),'MM/DD/YYYY')
Not sure of the syntax.
But what you are doing is converting it to a char so you can format it then you are converting it back to a date to be passed to you asp page.

Ordinary Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top