Solved

Displaying Oracle DateTime field in .NET GridView

Posted on 2008-10-28
6
636 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
ID: 22826651
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
ID: 22826697
Try just selecting the Date like this:
SELECT TO_CHAR(YourDateFieldName, 'DD/MM/YY') FROM myTable
0
 
LVL 14

Expert Comment

by:CtrlAltDl
ID: 22826702
Doh, I guess Pra4444 beat me to it.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Closing Comment

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

Expert Comment

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

Hope this helps
-M3mph15
0
 

Author Comment

by:sydneyram
ID: 22858484
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Server Error 11 47
Error in script 11 47
C# 2015 Downloading text file and preserving the line breaks 5 20
ASP.NET gridview select textbox on focus 2 15
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

867 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

16 Experts available now in Live!

Get 1:1 Help Now