format for datetimepicker

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lab3terch
    New Member
    • Oct 2006
    • 22

    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(DateIn terval.Day, d2, d1)

    Thanks for any guidance.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by lab3terch
    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:
    Code:
    Label1.Caption = Format(d1,"d") ' Extract day of month.
    Last edited by Killer42; Sep 14 '07, 01:42 PM. Reason: Reduced excessive quote block

    Comment

    • schandraram
      New Member
      • Sep 2006
      • 5

      #3
      Originally posted by lab3terch
      I am working on a program where I have two datetimepickers ...
      What version of VB are you using?

      Maybe you could try:
      Code:
      totdays = DateDiff("d",d1,d2)
      Chandra
      Last edited by Killer42; Sep 14 '07, 01:41 PM. Reason: Reduced excessive quote block

      Comment

      • Suresh P
        New Member
        • Sep 2007
        • 1

        #4
        Originally posted by lab3terch
        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..?
        Last edited by Killer42; Sep 14 '07, 01:38 PM. Reason: Reduced excessive quote block

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by Suresh P
          Better try this..
          Thanks Suresh. This might be a bit late, though. The last message in this thread was in November last year.

          Comment

          Working...