• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4461
  • 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

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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