Solved

set datetimepicker value to first day of the month

Posted on 2004-08-16
3
3,989 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

919 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

14 Experts available now in Live!

Get 1:1 Help Now