Author |
Topic |
aden
Starting Member
23 Posts |
Posted - 2006-09-20 : 13:03:31
|
how can i get the value of a specific record?i need this for this kind of querywhere (ondate+userdef09/<-i need to get the value o this/)=(date today)they're in the same table.can anyone show me how to query this? |
|
JoeNak
Constraint Violating Yak Guru
292 Posts |
Posted - 2006-09-20 : 13:10:51
|
I think you're going to have to post a little more info.Are you looking for this?SELECT fieldsFROM tableWHERE Convert(datetime, (ondate + userdef09), xxx) = GetDate() --xxx = date format codeSomehow ondate + userdef09 needs to convert to a date. |
 |
|
aden
Starting Member
23 Posts |
Posted - 2006-09-20 : 13:12:39
|
give me an example of a format code? i'll use this in goldbox...thanks |
 |
|
JoeNak
Constraint Violating Yak Guru
292 Posts |
Posted - 2006-09-20 : 13:18:56
|
101 = US (mm/dd/yy)102 = ANSI (yy/mm/dd) |
 |
|
JoeNak
Constraint Violating Yak Guru
292 Posts |
Posted - 2006-09-20 : 13:19:22
|
What are the data types for ondate and userdef09? |
 |
|
aden
Starting Member
23 Posts |
Posted - 2006-09-20 : 13:23:12
|
ondate contains date while userdef09 caontains number. i use it to represent no of days to add to ondate |
 |
|
JoeNak
Constraint Violating Yak Guru
292 Posts |
Posted - 2006-09-20 : 13:25:46
|
Try this...SELECT fieldsFROM tableWHERE DATEADD(dd, userdef09, ondate) = DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))If ondate contains times then you'll either need to strip the time off of ondate for the comparison or change it to a range (>= And <; Between; etc...) |
 |
|
aden
Starting Member
23 Posts |
Posted - 2006-09-20 : 13:28:12
|
there is an error. tried it in goldbox5 and goldmine. |
 |
|
JoeNak
Constraint Violating Yak Guru
292 Posts |
Posted - 2006-09-20 : 13:31:18
|
What does the error say? |
 |
|
aden
Starting Member
23 Posts |
Posted - 2006-09-20 : 13:34:17
|
just syntax error.SELECT * from conthist WHERE DATEADD(dd, userdef09, ondate) = DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))can you check this? |
 |
|
JoeNak
Constraint Violating Yak Guru
292 Posts |
Posted - 2006-09-20 : 13:38:28
|
Does it run? What am I checking? |
 |
|
aden
Starting Member
23 Posts |
Posted - 2006-09-20 : 13:45:35
|
the statement doesn't run.:( |
 |
|
JoeNak
Constraint Violating Yak Guru
292 Posts |
Posted - 2006-09-20 : 13:54:14
|
Doesn't run? What's the error? You said ondate was a datetime datatype and userdef09 is an int, correct?Doesn't return data? Do the dates in ondate include times? If so you need to take that into account in the where clause..WHERE DATEADD(dd, userdef09, ondate) >= DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE()))AND DATEADD(dd, userdef09, ondate) < DATEADD(dd, 1, DATEDIFF(dd, 0, GETDATE())) |
 |
|
X002548
Not Just a Number
15586 Posts |
|
aden
Starting Member
23 Posts |
Posted - 2006-09-20 : 14:00:12
|
ondate doesn't contain time while userdef09 is an int.i think there's something wrong with goldmine. it seems that it doesn't support getdate function. |
 |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2006-09-20 : 14:01:04
|
What the heck is goldmine ?- Jeff |
 |
|
X002548
Not Just a Number
15586 Posts |
|
aden
Starting Member
23 Posts |
Posted - 2006-09-20 : 14:05:17
|
goldmine is some sort of a system where it manages your contacts and your transactions with them and stuffs like that...it supports dbase and sql query.. |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-09-20 : 18:10:00
|
So is goldmine running on MS SQL Server ? KH |
 |
|
|