---
title: "how get date in c# dateTimePicker control"  
description: "how get date in c# dateTimePicker control"  
author: "Kenny Tangnde"  
published: 2011-10-14  
updated: 2011-10-16  
canonical: https://www.mindstick.com/forum/328/how-get-date-in-c-sharp-datetimepicker-control  
category: "c#"  
tags: ["c#"]  
reading_time: 3 minutes  

---

# how get date in c# dateTimePicker control

Hi All,

I encountered some problems, See details below:

how get date in c# dateTimePicker control,i need date only.such as:2011-10-15 (yyyy-month-day).

Can not immediately [update](https://www.mindstick.com/forum/156353/what-is-hummingbird-update) the data in treeView1_NodeMouseClick event.

see code below:

[private](https://www.mindstick.com/blog/11097/java-access-modifiers-the-public-and-the-private-modifiers) void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)\
{\
dataGridView1.DataSource = ""; \
try\
{\
\
[string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) AccessAddress = System.IO.Path.GetFullPath("PSRecord.mdb");\
//con = new OleDbConnection(@"[provider](https://answers.mindstick.com/qa/92701/who-is-the-best-telecom-solution-provider)=microsoft.ace.oledb.12.0;persist securityInfo=false;[data source](https://www.mindstick.com/interview/808/what-is-a-data-source)=" + AccessAddress);\
con = new OleDbConnection(@"provider=microsoft.jet.oledb.4.0;data source=" + AccessAddress);\
con.Open();\
cmd = new OleDbCommand("[select](https://www.mindstick.com/forum/160534/orderby-then-select-vs-select-then-orderby-performance) * from Record where [driver](https://yourviews.mindstick.com/view/80820/ola-driver-rude-behavior-with-mindstick-owners)='" + treeView1.SelectedNode.Text.ToString() + "'", con);\
ds = new [DataSet](https://www.mindstick.com/articles/19/dataset)();\
adapter = new OleDbDataAdapter(cmd);\
adapter.Fill(ds);\
dataGridView1.DataSource = ds.Tables[0];

}\
catch ([Exception](https://www.mindstick.com/articles/1824/objective-c-exception-handling) ex)\
{

MessageBox.Show(ex.ToString());\
}\
finally\
{\
con.Close();\
}\
}

i need help now,Thanks!

## Replies

### Reply by Kenny Tangnde

Hi Haider M Rizvi,

Thank you for reminding me, i will correct.

Thanks.

### Reply by Anonymous User

Hi Aken H,

It is always a good habbit to ask someone if you get stuck some where, and I appretiate you do so to get your queries solved. But I have a suggestion for you so that you can get your answer more quickly.

Please do make sure that if you have more than one query always start a seperate thread for each problem so that each of your problem get noticed individually.

Hope, you got all your problems solved here and you will be following the the suggestions provided above in near future.

Thanks.

### Reply by John Smith

you got it ...is it working now?

### Reply by Kenny Tangnde

x86 can run it in XP sp2 environment?

thanks!

### Reply by Uttam Misra

To resolve this issue open the project in Visual Studio : \
\
1. From the solution explorer right-click your project then click Properties\
2. Click the Build tab\
3. Change Platform target from: Any CPU to x86\
4. Re-build your solution

### Reply by Kenny Tangnde

Where to set?

### Reply by Uttam Misra

\
Are you running your application on x64 or x86 version of Windows?

### Reply by Kenny Tangnde

client system is XP sp2

### Reply by Uttam Misra

are you working with 64bit system?

### Reply by Kenny Tangnde

I have a problem,client run my program error occurred,Error content is:The 'microsoft.jet.oledb.4.0' provider is not registered on the local machine.

Code is as follows:

private void frmMain_Load(object sender, EventArgs e)\
{\
string AccessAddress=System.IO.Path.GetFullPath("PSRecord.mdb");\
//con = new OleDbConnection(@"provider=microsoft.ace.oledb.12.0;persist securityInfo=false;data [source](https://www.mindstick.com/interview/840/what-happens-if-the-both-source-and-destination-are-named-same)=" + AccessAddress);\
con = new OleDbConnection(@"provider=microsoft.jet.oledb.4.0;data source=" + AccessAddress);\
con.Open();\
cmd = new OleDbCommand("select drivername from driver", con);\
reader = cmd.ExecuteReader();\
TreeNode parent = treeView1.Nodes.Add("DriverName");\
TreeNode child;\
parent.ForeColor = Color.Red;\
while (reader.Read())\
{\
//comboBox1.Items.Add(reader["DriverName"]);\
child = parent.Nodes.Add(reader.GetValue(0).ToString());\
child.ForeColor = Color.Blue;\
\
}\
parent.ExpandAll();\
reader.Close();\
con.Close();

\
}

thanks very much.

### Reply by Kenny Tangnde

Hi Uttam Misra,

You help me to solve the first problem, the problem is now the second left.

thanks for your help.

### Reply by Uttam Misra

Aken...\
Here you go...check this article... [DateTimePicker Control in C#.Net](https://www.mindstick.com/Articles/399/datetimepicker-control-in-c-sharp-dot-net)


---

Original Source: https://www.mindstick.com/forum/328/how-get-date-in-c-sharp-datetimepicker-control

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
