• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4550
  • Last Modified:

set datetimepicker value to first day of the month

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
jxharding
Asked:
jxharding
  • 2
1 Solution
 
Fahad MukhtarDistinguished EngineerCommented:
string Date1 = DateTime.Today.Month + "/1/" + DateTime.Today.Year;
dateTimePicker1.Value = Convert.ToDateTime(Date1);
0
 
Fahad MukhtarDistinguished EngineerCommented:
[vb.net]
dim Date1  as string = DateTime.Today.Month + "/1/" + DateTime.Today.Year
dateTimePicker1.Value = Convert.ToDateTime(Date1)
0
 
jxhardingAuthor Commented:
DateTime.Today.Month & "/1/" & DateTime.Today.Year
thanks desp!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now