Probleum in format function in vb.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • veer
    New Member
    • Jul 2007
    • 198

    Probleum in format function in vb.net

    Hi
    i used the following format function in vb6.0 it works fine
    Format(DTPFromD ate & " 00:00:00", "dd/mm/yyyy HH:MM:SS AMPM")

    but when i use same format function in vb.net it shows output like this
    MM/dd/yyyy HH:MM:SS AMPM

    please give some idea about vb.net format function

    reGArds
    varinder
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    That format you listed does not appear to match correct formatting.
    From what I can tell you want this format: "dd/MM/yyyy hh:mm:ss tt"
    You should also be useing the DateTime object and it's .ToString() function.

    .ToString("dd/MM/yyyy hh:mm:ss tt")

    On second look it seems like you are trying to "mask out" the time values?
    In which case just:
    .ToString("dd/MM/yyyy")
    would give you the date value.

    Comment

    • veer
      New Member
      • Jul 2007
      • 198

      #3
      Hi
      Thanks for reply
      but i am not understanding can you give an example

      thanks in advance

      Originally posted by Plater
      That format you listed does not appear to match correct formatting.
      From what I can tell you want this format: "dd/MM/yyyy hh:mm:ss tt"
      You should also be useing the DateTime object and it's .ToString() function.

      .ToString("dd/MM/yyyy hh:mm:ss tt")

      On second look it seems like you are trying to "mask out" the time values?
      In which case just:
      .ToString("dd/MM/yyyy")
      would give you the date value.

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        DTPFromDate is an instance of the datetime object yes?

        DTPFromDate.ToS tring("dd/MM/yyyy hh:mm:ss tt")
        or
        DTPFromDate.ToS tring("dd/MM/yyyy")

        if the start date was for "May 21st 2008, 9:51:30 AM" then the first one would print out:
        "21/05/2008 09:51:30 AM"
        And the 2nd one would print out:
        "21/05/2008"

        Comment

        • veer
          New Member
          • Jul 2007
          • 198

          #5
          Hi
          i use this query

          sQuery = "Insert into " & txttablename.Te xt & " In '" & txtmaster.Text & "' select * from " & sTableName & " In '" & txtpath.Text & "\" & sArrayFolder(ic ount) & "\" & sDirFolder & "' where YP1VStartTime >= # " & Format(DTPFrom. ToString ("dd/MM/yyyy hh:mm:ss tt")) & " # and Yp1VEndTime <= # " & Format(DTPTo.To String ("MM/dd/yyyy hh:mm:ss tt")) & " # "

          it shows the error
          "Overload resolution failed because no accessible 'ToString' accepts this number of arguments."
          is there any method to show date with time like this i did this in vb6.0 using format function but not getting in vb.net

          Yp1EStartTime >= #05/01/2008 12:00:00 AM# AND Yp1EEndTime <= #05/23/2008 11:59:59 PM#

          thanks in advance




          Originally posted by Plater
          DTPFromDate is an instance of the datetime object yes?

          DTPFromDate.ToS tring("dd/MM/yyyy hh:mm:ss tt")
          or
          DTPFromDate.ToS tring("dd/MM/yyyy")

          if the start date was for "May 21st 2008, 9:51:30 AM" then the first one would print out:
          "21/05/2008 09:51:30 AM"
          And the 2nd one would print out:
          "21/05/2008"

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            What kind of objects are DTPFrom and DTPTo? I thought they were DateTime objects.
            Also, why are you using the Format() function still?

            Comment

            • veer
              New Member
              • Jul 2007
              • 198

              #7
              yes you are right
              DTPFrom and DTPTo are date time object
              because i want to access the value from access database lies between the two selected dates
              and the value in column of access is like "22/05/2008 02:55:25" so that i want to set the fromat of time liest between 12:00:00 am to 11:59:59 pm
              that's why i use the format function but it is not working in vb.net it works fine in vb6.0




              Originally posted by Plater
              What kind of objects are DTPFrom and DTPTo? I thought they were DateTime objects.
              Also, why are you using the Format() function still?

              Comment

              • Plater
                Recognized Expert Expert
                • Apr 2007
                • 7872

                #8
                Although I doubt your access is really "keeping" the dates as any format other then a datetime number:
                DTPFrom.ToStrin g ("dd/MM/yyyy hh:mm:ss tt"))
                is already formatting them into the correct display format for that.


                Those columns are Date/time fields in the database yes?

                Comment

                Working...