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!

can I convert a number to a date?

Status
Not open for further replies.

PushCode

Programmer
Dec 17, 2003
573
US
I'm pulling a number formatted field (<%# Eval("AP_PAYMENT_DATE_FK_KEY") %>) from an Oracle table, and I want to display it as a date.

Here's what it looks like in the database: 20081201

I was hoping I could do something like this # Eval("AP_PAYMENT_DATE_FK_KEY", "{0:mm/dd/yyyy}") %> to display it in a date format...but no go.

Any help would be greatly appreciated. Thanks!
 
why do not you take care of it in your sql statement like this:

01300901

substr(l.letting,3,2)||'-'|| substr(l.letting,5,2)||'-'|| substr(l.letting,1,2) LetDate

and this is how it looks like

01-30-09
 
I'm not familiar with this LetDate functionality and I don't see any documentation on it. Can you tell me what it should look like in my query? Remember, I'm querying and Oracle database.

So say here's my query:
SELECT a.AP_PAYMENT_DATE_FK_KEY, b.AC_CHECK_NUMBER FROM XXGDW_AP_PAYMENT_SCHED_F a, XXGDW_AP_PAYMENT_SCHED_MISC_D b
WHERE a.ap_inv_payment_pk = b.ap_inv_payment_pk

What should it look like using your solution? Thanks!
 
substr(AP_PAYMENT_DATE_FK_KEY,7,2)||'-'||
substr(AP_PAYMENT_DATE_FK_KEY,5,2)||'-'||
substr(AP_PAYMENT_DATE_FK_KEY,1,4)||'-'||

using your data: 20081201 if you include the above code in your sql you should get this 01-12-2008
 
Any formatting should be done in the front end, not SQL. SQL is for data retreival and manipulation, not presentaion.
 
jbenson001, can you provide an example how this can be done differently. thanks
 
YOu can use the .NET format() method, also the .ToString("Format") with a format mask. There are many examples online and in help. I will try to post a good example late r if I get the time.
 
Went down that road and got lost. That's why I went the SQL route instead.
 
There much more you can do with(and faster) a front end than in SQL, formatting, calculations, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top