Author |
Topic |
funketekun
Constraint Violating Yak Guru
491 Posts |
Posted - 2007-05-25 : 11:59:18
|
how do i get yesterdays records only? |
|
rmiao
Master Smack Fu Yak Hacker
7266 Posts |
Posted - 2007-05-25 : 12:01:23
|
Does your table have datetime column? |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-05-25 : 12:03:26
|
[code]where datecol > dateadd(day, datediff(day, 0, getdate()), -1)[/code] KH |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-05-25 : 12:41:13
|
Just yesterdays? Or including today's also? |
 |
|
funketekun
Constraint Violating Yak Guru
491 Posts |
Posted - 2007-05-25 : 13:31:59
|
khtan,looks like it doesn't work inside an open query.select top 1 * from openquery(dccs_danville, 'select * from downloadeddatetime where downloadeddatetime >dateadd(day, datediff(day, 0, getdate()), -1)') |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-05-25 : 13:34:58
|
"open query" won't make a difference in this instance.You have a table called "downloadeddatetime" which has a column which is also called downloadeddatetime, is that correct?If [downloadeddatetime] could have a time of midnight, then you need to use ">=" instead of just "="Kristen |
 |
|
funketekun
Constraint Violating Yak Guru
491 Posts |
Posted - 2007-05-25 : 13:39:47
|
my bad the table is called [tblpicktickethdr]select top 1 * from openquery(dccs_danville, 'select * from [tblpicktickethdr] where downloadeddatetime >dateadd(day, datediff(day, 0, getdate()), -1)')But still getting the same error.Even with this: It shows the same error.select top 1 * from openquery(dccs_danville, 'select * from [tblpicktickethdr] where downloadeddatetime > getdate()') |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-05-25 : 13:45:08
|
"But still getting the same error"What is the error?You didn't try my suggestion about ">=" then?What does SELECT * from [tblpicktickethdr] where downloadeddatetime >= '20070524'give you (i.e. if you run it directly on "dccs_danville")? If there are zero results then there is no data in that range.Kristen |
 |
|
funketekun
Constraint Violating Yak Guru
491 Posts |
Posted - 2007-05-25 : 14:03:14
|
kristen,[easysoft][interbase] dynamic sql error, sql error code = -804, function unknow, getdate.SELECT * from [tblpicktickethdr] where downloadeddatetime >= '20070524'conversion error from string "20070202" |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-05-25 : 14:12:00
|
Yeah, well interbase presumably doesn't have a GetDate() function for todays date. May well not have DATEADD or DATEDIFF either.It would have saved folk here time if you had mentioned that you were querying a non-SQL Server database, given that this is a SQL Server only forum!I have NO IDEA how the querySELECT * from [tblpicktickethdr] where downloadeddatetime >= '20070524'gives the error:conversion error from string "20070202"Kristen |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-05-25 : 14:13:28
|
What's your connection with SQL USA? (as per the image in your Profile) |
 |
|
funketekun
Constraint Violating Yak Guru
491 Posts |
Posted - 2007-05-25 : 14:39:23
|
is there any way to do it without using the functions? |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-05-25 : 14:42:11
|
Well it doesn't seem to work even with a CONSTANT value for yesterday's date, so I can't see how a function would improve that, but it seems reasonable to me that "interbase" would have a mans of getting the "now" Date & time, and manipulating date/time to add/subtract a day etc.Either way, I know nothing about "interbase" so I can't help further.You didn't answer my question:"What's your connection with SQL USA? (as per the image in your Profile)"Kristen |
 |
|
funketekun
Constraint Violating Yak Guru
491 Posts |
Posted - 2007-05-25 : 16:12:55
|
i can do this.select * from openquery(dccs_danville, 'select downloadeddatetime from tblpicktickethdr where downloadeddatetime >= ''25-may-2007''') |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-05-25 : 16:21:08
|
i'm surprised that you can't use ISO format for dates:yyyyMMdd_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
funketekun
Constraint Violating Yak Guru
491 Posts |
Posted - 2007-05-25 : 16:23:33
|
yeah. its interesting. I wonder if im able to get yesterdays info now. |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-05-25 : 16:37:07
|
well... are you?_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
Kristen
Test
22859 Posts |
Posted - 2007-05-26 : 03:18:18
|
Clearly you could just create the openquery as a text string.Have you checked the Interbase manual for their "safe format" for dates?Kristen |
 |
|
funketekun
Constraint Violating Yak Guru
491 Posts |
Posted - 2007-05-26 : 17:51:04
|
create openquery as a text string? you mean using dymanic sql? |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-05-26 : 18:04:02
|
openquery can't accept variables._______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
funketekun
Constraint Violating Yak Guru
491 Posts |
Posted - 2007-05-26 : 19:07:03
|
so i cant get yesterdays info? |
 |
|
Next Page
|