error in printing the date

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

    error in printing the date

    hello
    i want to access the data from sql server which lies in particular date . I select the date from my vb form DTPicker and my query is

    Str3 = "SELECT * FROM New_Rec where From_Date = # " & Format(DTPFrom & " 00:00:00", "dd/mm/yyyy hh:mm:ss AMPM") & " # AND To_Date = # " & Format(DTPTo & " 23:59:59", "dd/mm/yyyy hh:mm:ss AMPM") & "#"

    where from_date and To_date are date column and DTPFrom , DTPTo are DTPicker .
    In DTPFrom, the format of value is 01\dec\2007 07:00 AM
    in DTPTo , the format of value is 04\apr\2007 02:30 PM
    can i change the format of DTPicker or chechk the query and give perfect code
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Try setting and using the custom format and parse the value before processing in database.

    Comment

    • veer
      New Member
      • Jul 2007
      • 198

      #3
      Hi
      this is my query it does not produce any error but can't insert any value into new_rec table

      Str3 = "insert into new_rec SELECT * FROM new where From_Date = '" & Format(DTPFrom & " 00:00:00", "dd/MMM/yyyy hh:mm:ss AMPM") & "' AND To_Date = '" & Format(DTPTo & " 23:59:59", "dd/MMM/yyyy hh:mm:ss AMPM") & "'"
      rs1.Open Str3, con, adOpenDynamic, adLockBatchOpti mistic, adCmdText







      Originally posted by debasisdas
      Try setting and using the custom format and parse the value before processing in database.

      Comment

      • pureenhanoi
        New Member
        • Mar 2007
        • 175

        #4
        Originally posted by veer
        Hi
        this is my query it does not produce any error but can't insert any value into new_rec table

        Str3 = "insert into new_rec SELECT * FROM new where From_Date = '" & Format(DTPFrom & " 00:00:00", "dd/MMM/yyyy hh:mm:ss AMPM") & "' AND To_Date = '" & Format(DTPTo & " 23:59:59", "dd/MMM/yyyy hh:mm:ss AMPM") & "'"
        rs1.Open Str3, con, adOpenDynamic, adLockBatchOpti mistic, adCmdText
        Try:
        Con.Excute Str3

        Comment

        Working...