Date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mclueless
    New Member
    • Jan 2008
    • 56

    Date

    the date Formats in VB6 n in access are different. i have written an insert query for inserting all details including date into the database but it is not working. i think it is because of this format difference. how do i handle it???
  • lotus18
    Contributor
    • Nov 2007
    • 865

    #2
    Originally posted by mclueless
    the date Formats in VB6 n in access are different. i have written an insert query for inserting all details including date into the database but it is not working. i think it is because of this format difference. how do i handle it???
    Can you post your sql statement here? Did you check the datatypes of your fields?
    Did you enclosed the dates in your sql query with #?

    Rey Sean

    Comment

    • shuvo2k6
      New Member
      • Jan 2008
      • 68

      #3
      Originally posted by mclueless
      the date Formats in VB6 n in access are different. i have written an insert query for inserting all details including date into the database but it is not working. i think it is because of this format difference. how do i handle it???


      Hey,
      u can take the Date as String, then perform ur other tasks.

      Comment

      • daniel aristidou
        Contributor
        • Aug 2007
        • 494

        #4
        Originally posted by shuvo2k6
        Hey,
        u can take the Date as String, then perform ur other tasks.
        This is unadvisable.... .

        Comment

        • creative1
          Contributor
          • Sep 2007
          • 274

          #5
          You should format your data before your query in a format that is acceptable in Access something like this:
          Format$(txtdate .Text, "m/dd/yy")
          Regards

          Comment

          • shuvo2k6
            New Member
            • Jan 2008
            • 68

            #6
            Originally posted by daniel aristidou
            This is unadvisable.... .
            Hi daniel aristidou,
            Text1.text is String or other type Data in creative1 ?. Reply me. If u create any mad like comment, u must think before abt that.

            Thnks,
            shuvo2k6

            Comment

            • creative1
              Contributor
              • Sep 2007
              • 274

              #7
              In my reply I assumed you have entered your data in a textbox that you want to convert. I think you better post what you have in your code. It will be far easy to suggest any thing that will help you.

              Comment

              • VACEPROGRAMER
                Banned
                New Member
                • Nov 2007
                • 167

                #8
                Why don't you samply type DATE FORMATS in VB help. And you have what you want

                *VACE*

                Comment

                • BradleyS
                  New Member
                  • Feb 2008
                  • 1

                  #9
                  please post your insert code...

                  Comment

                  • shuvo2k6
                    New Member
                    • Jan 2008
                    • 68

                    #10
                    In VB6:

                    Private Sub Command1_Click( )
                    Text1.Text = Format(Date, "dd mmmm, yyyy")
                    End Sub

                    Comment

                    • mclueless
                      New Member
                      • Jan 2008
                      • 56

                      #11
                      rs.Open "insert into Invoice_master( Inv_No,Inv_Date ,Inv_Type,Cust_ Code,Salesman_C ode,Due_Date) values(" & Val(txtInvNo.Te xt) & ",'" & txtDate.Text & "','" & txtInvType.Text & "'," & Val(txtCustCode .Text) & "," & Val(txtSaleCode .Text) & ",'" & txtDue.Text & "')", con, 3, 3


                      This is the insert statement. tell me where to make changes.

                      Comment

                      • lotus18
                        Contributor
                        • Nov 2007
                        • 865

                        #12
                        Originally posted by mclueless
                        rs.Open "INSERT INTO Invoice_master( Inv_No,Inv_Date ,Inv_Type,Cust_ Code,Salesman_C ode,Due_Date) VALUES " & Val(txtInvNo.Te xt) & ",'" & txtDate.Text & "','" & txtInvType.Text & "'," & Val(txtCustCode .Text) & "," & Val(txtSaleCode .Text) & ",'" & txtDue.Text & "')", con, 3, 3


                        This is the insert statement. tell me where to make changes.
                        Hi

                        Change your codes to
                        [code=vb]
                        rs.Open "INSERT INTO Invoice_master( Inv_No,Inv_Date ,Inv_Type,Cust_ Code,Salesman_C ode,Due_Date) VALUES (" & Val(txtInvNo.Te xt) & ",#" & txtDate.Text & "#,'" & txtInvType.Text & "'," & Val(txtCustCode .Text) & "," & Val(txtSaleCode .Text) & ",#" & txtDue.Text & "#)", con, 3, 3
                        [/code]

                        Rey Sean
                        Last edited by lotus18; Feb 3 '08, 11:26 AM. Reason: .

                        Comment

                        • mclueless
                          New Member
                          • Jan 2008
                          • 56

                          #13
                          Originally posted by lotus18
                          Hi

                          Change your codes to
                          [code=vb]
                          rs.Open "INSERT INTO Invoice_master( Inv_No,Inv_Date ,Inv_Type,Cust_ Code,Salesman_C ode,Due_Date) VALUES (" & Val(txtInvNo.Te xt) & ",#" & txtDate.Text & "#,'" & txtInvType.Text & "'," & Val(txtCustCode .Text) & "," & Val(txtSaleCode .Text) & ",#" & txtDue.Text & "#)", con, 3, 3
                          [/code]

                          Rey Sean



                          I tried the above query bt I am getting the following error....

                          Syntax error in date in query expression '# #' .

                          Comment

                          • lotus18
                            Contributor
                            • Nov 2007
                            • 865

                            #14
                            Originally posted by mclueless
                            I tried the above query bt I am getting the following error....

                            Syntax error in date in query expression '# #' .
                            Really?, May I see your sample value in txtDate and txtDue. Are your Inv_Date and Due_Date are Date/Time Datatypes?

                            Rey Sean

                            Comment

                            • mclueless
                              New Member
                              • Jan 2008
                              • 56

                              #15
                              Originally posted by lotus18
                              Really?, May I see your sample value in txtDate and txtDue. Are your Inv_Date and Due_Date are Date/Time Datatypes?

                              Rey Sean
                              They are Short Dates....
                              sample:-3/2/2008

                              Comment

                              Working...