Solved

Displaying Oracle DateTime field in .NET GridView

Posted on 2008-10-28
6
634 Views
Last Modified: 2013-12-19
Experts,

I need your assistance in converting a Datetime field returned from an Oracle database into a .NET DateTime field which is displayed in a Grid View which shows only the Date part and not the Time
(For Eg: the Value in GridView is  6/11/1986 12:00:00 AM       and I want it as just c/11/1986)

I cannot create that column as a bound field as my DataSet returns variable columns everytime. So, there might or might not be a DateField in the DataSet too depending on the Query I run against the Database.

An early response would be really appreciated and helpful.

Thanx.
0
Comment
Question by:sydneyram
6 Comments
 
LVL 12

Accepted Solution

by:
Pra4444 earned 500 total points
Comment Utility
Can you not retrieve the value from the Oracle as a character string using

select to_char(date,'MM\DD\YYYY') from your_query

0
 
LVL 14

Expert Comment

by:CtrlAltDl
Comment Utility
Try just selecting the Date like this:
SELECT TO_CHAR(YourDateFieldName, 'DD/MM/YY') FROM myTable
0
 
LVL 14

Expert Comment

by:CtrlAltDl
Comment Utility
Doh, I guess Pra4444 beat me to it.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Closing Comment

by:sydneyram
Comment Utility
Awesome!!! thanks a lot for the quick response.
0
 
LVL 6

Expert Comment

by:M3mph15
Comment Utility
Hi,
You can set the DataFormatString to something like {0:dd/MM/yyyy}.

Hope this helps
-M3mph15
0
 

Author Comment

by:sydneyram
Comment Utility
M3mph15,

In my case it is an autogenerated column and not databound so I cannot you the dataformatstring property.


Pra4444,
Is there any other way of doing the same on the .NET side? I have to make a lot of logical changes in my code if i incorporate the TO_CHAR method of doing it.

Thanks.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now