|
-
Feb 17th, 2006, 12:38 PM
#1
Thread Starter
Lively Member
[RESOLVED] help with SQL and dates and update
1.How can you select the fields with an SQL statement and using a date column. For example:
VB Code:
.RecordSource = "Select * from tableA where Adate between " & txtDate1 & " and " & txtDate 2
2.Can I get somehow the records that i need and perform calculations with them and save the calculation result in another column in the same records?
for example, with a loop add number1 and number2 to result which all are columns in my database? I can send the code if you prefer...
in a for loop:
(.Fields(10)) = (.Fields(2))+(.Fields(3))
how do I update (.Fields(10))??
-
Feb 17th, 2006, 12:40 PM
#2
Re: help with SQL and dates and update
That depends on what database you are using.
Access wants # arounds dates and SQL Server wants single quotes.
-
Feb 17th, 2006, 08:05 PM
#3
Frenzied Member
Re: help with SQL and dates and update
 Originally Posted by rasty1611
1.How can you select the fields with an SQL statement and using a date column. For example:
VB Code:
.RecordSource = "Select * from tableA where Adate between " & txtDate1 & " and " & txtDate 2
Code:
.RecordSource = "Select * from tableA where Adate between #" & txtDate1 & "# and #" & txtDate 2 & "#"
also don't know if it's a type, but txtDate 2 should be txtDate2 - no space.
2.Can I get somehow the records that i need and perform calculations with them and save the calculation result in another column in the same records?
for example, with a loop add number1 and number2 to result which all are columns in my database? I can send the code if you prefer...
in a for loop:
(.Fields(10)) = (.Fields(2))+(.Fields(3))
how do I update (.Fields(10))??
That would be an UPDATE statement in SQL.
I wouldn't do it your intended way, maybe a matter of preference. I'd calculate Field2 + Field3, then Update field 10, using SQL. It's (almost) always faster, and easier to trace errors. IMHO. I
Tengo mas preguntas que contestas
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|