converting an object (from access db) to a datetime format?

At present i am unsing the below code:

lblroundDate.Text = objRdr["roundDate"]+"";

This displays my date from the database in the following format:

27/05/2007 00:00:00

I am trying to loose the time on the end and just have the date, i have tried playing around with ToLongDateString(); but keep getting comp errors, any help appreciated. 

6/30/2007 1:43:04 PM 91979 articles. 4 followers. Follow

5 Replies

Similar Articles

[PageSpeed] 24

Hi, you can use a Date datatype to get just tghe date in your string. Like this


Date myDate = objRdr["roundDate"];
String JustDate = myDate.ToShortDateString;
lblroundDate.Text = JustDate;

 That way you can have 27/05/2007

I hope this can help.

6/30/2007 2:03:54 PM

does not seem to like "Date" as a type? am i missing something here?

The type or namespace name 'Date' could not be found (are you missing a using directive or an assembly reference?)

6/30/2007 2:18:45 PM

DateTime myDate = (DateTime)objRdr["roundDate"];
lblroundDate.Text = myDate.ToShortDateString;

6/30/2007 2:39:22 PM

I'm sorry I messed out but I'm used to VB.Net. Here is the Correct code:

DateTime myDate = Convert.ToDateTime(objRdr["roundDate"]);
String sJustDate;
sJustDate = myDate.ToShortDateString();
lblroundDate.Text = sJustDate;


6/30/2007 2:53:25 PM

thnaks leonm, works great!

Kipo i am afraid your code still gives me an error! But not to worry!!

6/30/2007 5:25:21 PM

Similar Artilces:

Convert .NET DateTime format to SQL DateTime format
Hi!!I'd like to know if there is a function to convert the DateTime format used in C# (VS2005) : dd/mm/yyyy HH:mm:ss to the format used in SQL Databases: yyyymmdd HH:mm:ssThanks folks!...

Convert Existing User DB to Net .net MemberShip DB
Hey, Im looking to take my current Users DB and put those records into the new .net membership DB. I looked at the Membership Create User SP but im not sure if that sp is the only procedure that gets called when creating a user. I was wondering if any one else has had to do this and how should i go about it. I have about 100 users that i need to copy over. Thanks. This article has a bunch of links to Membership and security information in ASP.NET: For migrating 100 users over, you might just find it easiest to create a ...

Convert from Access DB to SQL DB....
Dear All,  I would like to convert from Access To SQL DB undervisual Studio.Net 2005... How can I do it easily, or if there any software to do this automaticlly, please your help..  Awaiting your valuable reply. Many thanks in advance for your cooperation and continuous support....Aح What version of MS Access are you using?Most of the Access versions like XP/2003 all have an upgrade wizard that allows you to convert your existing database to SQL Server.In Access 2003 I believe you can use the Upsizing Wizard which can be accessed from Tools -> Database Utilities -> Upsi...

How to convert format of a DateTime object to "yyyy-MM-dd" style
Hi all, i have a date in string data type. i m using Convert.ToDateTime function to convert this string date to DateTime object. When i get this date as a DateTime object it is in "dd-MM-yyyy" format. but i want to convert its format to "yyyy-MM-dd". Can anyone tell me how to convert the format of a DateTime object. I don't want the format with string data type. Please help me. Thanks in advance. once you got your object just do a .ToString("yyyy-MM-dd") on the end of it. Otherwise you'll probably have to change your server settings to be that f...

DB user, ownership and access to db objects
Hi all, I need to clarify a few things related to the sybase logins, database users/aliases, ownership of procedures and different copies of views (eg. views with the same name, but owned by different users). Can you please have a look at the following scenarios and tell me whether my assumptions are correct? Logins: 1. db1_dbo, valid user in db1 2. db2_dbo, valid user in db2 3. db2_admin, valid user in db1 and db2 4. myuser1 5. myuser2 6. myuser3 Databases: 1. db1, dbo == db1_dbo 2. db2, dbo == db2_dbo Aliases: 1. myuser1 is aliased to "dbo" in db2 2. myuse...

Accessing a Com object using Get Object
* Wasn't sure which section to put this in, but found similiar topics in here. We have a slight problem trying to access a COM Object. Reading some of the threads in this forum, people have mentioned trying to connect to a COM Object, but everyone has suggested using CreateObj. We cannot do this as the object is already created, we need to Get this object. Obviously you can use the GetObj command in VB6, but we cannot find away of Getting this object either through a webservice. Feel free to move this to the correct forum. Any help will be greatly recieved. Regards C ...

Issue when converting XML dateTime to .NET DateTime
Hi, I am experiencing an issue when deserializing XML dateTime nodes in ASP.NET in some timezones. The construct 0001-01-01T00:00:00.0000000+ZZ:ZZ where ZZ:ZZ is the timezone offset for the timezone on the current system should produce a DateTime value equalling the constant DateTime.MinValue when converted. This works some of the time, such as for the Paris time offset of +1: (CDate("0001-01-01T00:00:00.0000000+01:00") = DateTime.MinValue) = True But does not work for Sydney time offset of +10: (CDate("0001-01-01T00:00:00.0000000+10:00") = DateTime....

Dbi objects to access an MS Access Db
I'm having a problem getting Tran-ide to recognize my access 2000 database. I've created a system dsn called Midas and created the attached nnsyreg.dat file and put it into e:\sybase\ImpactClient-5_3\config directory. I've also put this file in my projects directory and still get the following message. Unable to connect to session Midas. Any Advice? Thanks Brent begin 666 nnsyreg.dat M4V5S<VEO;BY-:61A<PT*"4Y.3U1?4TA!4D5$7TQ)0E)!4ED@/2!D8G0R-VUS M;V1B8PT*"4Y.3U1?1D%#5$]265]&54Y#5$E/3B ]($Y.4V5S3T1"0T9A8W1O M<GD-"@E.3E]315-?4T525D52(#T@24U...

How to get DataTable object from DB and get Values from it
Here the code I use ...  SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);        SqlDataAdapter Adptr = new SqlDataAdapter("Select * from AccountType ", con );DataTable mytbl = new DataTable("tbl"); Adptr.Fill(mytbl)       if (mytbl.Rows[0][1].ToString()) == "Classic")  /// Here I gey a message : There is no row 0 in table .... I checked DataTable with Response.Write( mytbl.Rows.Count )  it gives me 0 ... What can be the pro...

Convert SQL Server DB to Access DB
Hi, I'm trying to convert a SQL Server 2000 database into a Access database because my hosting provider does not support SQL Server. I have tried the DTS, however it can only convert the tables, not the stored procedures. So is it possible to convert the stored procedures as well? I'm looking forwards to your response Phan Nguyen Hello, I believe you need some third-party components to do so, check the links below: MSSQL-to-Access 1.0 MSSQL Migration Toolkit v1.0 All are shareware tools, yuo can download and use them as a trial version. Regards.Bilal Hadiar, MCP, MCTS,...

Accessing a password protected Access 2002 DB from .Net
Here is my connection string: Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("trivia.mdb") & ";Database Password=jeuxdemots;" but I get the following error: Not a valid password. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.OleDb.OleDbException: Not a valid password. The password is the right one, what am I doing ...

Problem Getting Started
In have run the 1317set.bat file and still get the following error: Unable to get your db version please run version script against your db and restart your web application (go to update/scripts/ folder and run 1317set.bat). Any help to get me started would be much | Have you checked your connection string? This is sometimes caused by a faulty db connection. I am new to Rainbow and get the same error when trying to run it for the first time. Does not matter which of the following I comment out in web.config: <!-...

Innovation to ADO.NET
Matisse Software Inc. provides its native ADO.NET Data provider for Matisse 6.0, the Database for .NET. Matisse Software has pushed the envelope of Microsoft ADO.NET architecture and extended it into a powerful Object Access Services component for .NET. Matisse’s extension of ADO.NET demonstrates that ADO.NET can evolve beyond the Microsoft architecture to benefit .NET developers. Unlike the standard ADO.NET data provider, which returns data in a table format to integrate seamlessly with relational products, Matisse has extended the ADO.NET architecture to return data in an object format....

Howto: Convert sample SQL dB code to Access dB code?
Hello, In reference to the book: ASP.NET Web Matrix Starter Kit (ISBN: 0-7356-1856-9) Chapter 14 – Creating a Web-Based Calendar. The sample code works great when using an SQL server dB. However Web Matrix allows us to use an Access dB as well. My question is how do I convert the code found on page 275 to work with an Access dB? I have got the rest of the sample code in this chapter to work using Access, but I am not familiar with the proper way to convert this code: Sub DisplayAppointments(dateToDisplay As DateTime) labelSelectedDate.Text = dateToDisplay...

Web resources about - converting an object (from access db) to a datetime format? -

Facebook Begins Converting Users To HTTPS
Are you willing to sacrifice a little bit of speed for a lot more safety? Facebook is asking that very question with its announcement that it ...

Facebook No Longer Converting Groups Into Pages
Back when Facebook first launched Facebook Pages, many businesses and brands who had built up substantial audiences in their Facebook Groups ...

Vert - simply converting for iPhone, iPad, and iPod touch on the iTunes App Store
Get Vert - simply converting on the App Store. See screenshots and ratings, and read customer reviews.

Converting SIM Card to Micro SIM Card - Flickr - Photo Sharing!
Place new Micro SIM into the iPhone SIM card tray

Ayaan Hirsi Ali on Converting Muslims to Christianity - YouTube
Complete video at: Ayaan Hirsi Ali explains her support of missionary ...

Click go fears of converting print files
Is there a way to convert a print queue item to a .RTF or .PDF file? I like to save or email them. - The Sydney Morning Herald

Sudanese woman ordered to hang under sharia law for converting to Christianity gives birth
Khartoum, Sudan: A Christian Sudanese woman sentenced to hang for apostasy has given birth in jail, a Western diplomat said on Tuesday.

Imams warn against radicalism to Aboriginal inmates converting to Islam
The prison system has enlisted the help of ASIO to crack down on radicalisation behind bars amid revelations that Aboriginals are converting ...

Converting the world's companies one by one - The Science Show - ABC Radio National (Australian Broadcasting ...
Image: Trucks carrying logs make their way up a road in Jambi, Indonesia. A vast area of the Sumatran forest, and orangutan habitat, is being ...

Converting Churches Into Homes Is The Latest Hollywood Trend
You don't have to be a believer to be moved by the beauty of a church.

Resources last updated: 12/17/2015 1:09:00 PM