By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,057 Members | 1,346 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,057 IT Pros & Developers. It's quick & easy.

format for datetimepicker

P: 22
I am working on a program where I have two datetimepickers and need the difference in days between the two dates. I have the format property for both set to short. When I add the datetimepicker to a label it prints as 12:00:00AM instead of as a date.. How do I format this to return tghe day of the month selected in the picker?

Dim d1 As Date = DateTimePicker1.Value
Dim d2 As Date = DateTimePicker2.Value
totdays = DateDiff(DateInterval.Day, d2, d1)

Thanks for any guidance.
Nov 17 '06 #1
Share this Question
Share on Google+
4 Replies


Expert 5K+
P: 8,434
I am working on a program where I have two datetimepickers ...
The dtpicker would be returning a date variable, and when you print one of those or move to a string, time-only is the default format. The Format() function should do the trick. Just look up the parameters for date/time formats in the online help. Sample:
Expand|Select|Wrap|Line Numbers
  1. Label1.Caption = Format(d1,"d") ' Extract day of month.
Nov 17 '06 #2

P: 5
I am working on a program where I have two datetimepickers ...
What version of VB are you using?

Maybe you could try:
Expand|Select|Wrap|Line Numbers
  1. totdays = DateDiff("d",d1,d2)
  2.  
Chandra
Nov 17 '06 #3

P: 1
I am working on a program where I have two datetimepickers ...
Hi,
Better try this..
totdays = d2-d1
if you are using datepicker it works.. else..?
Sep 14 '07 #4

Expert 5K+
P: 8,434
Better try this..
Thanks Suresh. This might be a bit late, though. The last message in this thread was in November last year.
Sep 14 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.