Solved

set datetimepicker value to first day of the month

Posted on 2004-08-16
3
4,122 Views
Last Modified: 2008-01-09
hi, i have 2 datetimepickers on my form, but i would like the first one's default date to be the first day of the current month.
so in my form_load i tried
DateTimePicker1.Value = (" & Now.Year & " / " & Now.Month & " / 1)
but i get the error
Conversion from 'Double' to 'Date' requires calling the 'Date.FromOADate' method.
and the complete section in brackets is underlined
0
Comment
Question by:jxharding
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 19

Expert Comment

by:Desp
ID: 11808778
string Date1 = DateTime.Today.Month + "/1/" + DateTime.Today.Year;
dateTimePicker1.Value = Convert.ToDateTime(Date1);
0
 
LVL 19

Accepted Solution

by:
Desp earned 500 total points
ID: 11808783
[vb.net]
dim Date1  as string = DateTime.Today.Month + "/1/" + DateTime.Today.Year
dateTimePicker1.Value = Convert.ToDateTime(Date1)
0
 

Author Comment

by:jxharding
ID: 11809318
DateTime.Today.Month & "/1/" & DateTime.Today.Year
thanks desp!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …

733 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