468,301 Members | 1,526 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,301 developers. It's quick & easy.

format for datetimepicker

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
4 1434
Killer42
8,434 Expert 8TB
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
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
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
Killer42
8,434 Expert 8TB
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.

Similar topics

9 posts views Thread by Ed Crowley | last post: by
2 posts views Thread by faith | last post: by
1 post views Thread by Esref Durna | last post: by
14 posts views Thread by Charles A. Lackman | last post: by
2 posts views Thread by krishna murthy | last post: by
3 posts views Thread by Sam | last post: by
4 posts views Thread by Bill Nguyen | last post: by
5 posts views Thread by Terry | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.