Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 help in getting actual valueof a record

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 query

where (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 fields
FROM table
WHERE Convert(datetime, (ondate + userdef09), xxx) = GetDate() --xxx = date format code

Somehow ondate + userdef09 needs to convert to a date.
Go to Top of Page

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
Go to Top of Page

JoeNak
Constraint Violating Yak Guru

292 Posts

Posted - 2006-09-20 : 13:18:56
101 = US (mm/dd/yy)
102 = ANSI (yy/mm/dd)
Go to Top of Page

JoeNak
Constraint Violating Yak Guru

292 Posts

Posted - 2006-09-20 : 13:19:22
What are the data types for ondate and userdef09?
Go to Top of Page

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
Go to Top of Page

JoeNak
Constraint Violating Yak Guru

292 Posts

Posted - 2006-09-20 : 13:25:46
Try this...

SELECT fields
FROM table
WHERE 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...)

Go to Top of Page

aden
Starting Member

23 Posts

Posted - 2006-09-20 : 13:28:12
there is an error. tried it in goldbox5 and goldmine.
Go to Top of Page

JoeNak
Constraint Violating Yak Guru

292 Posts

Posted - 2006-09-20 : 13:31:18
What does the error say?
Go to Top of Page

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?
Go to Top of Page

JoeNak
Constraint Violating Yak Guru

292 Posts

Posted - 2006-09-20 : 13:38:28
Does it run? What am I checking?
Go to Top of Page

aden
Starting Member

23 Posts

Posted - 2006-09-20 : 13:45:35
the statement doesn't run.:(
Go to Top of Page

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()))
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-09-20 : 13:58:19
First, are talking about SQL Server?

And are you using Query Analyzer?

Read the hint link in my sig and post what it asks for

My Telepathy usb port is clogged



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page

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.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-09-20 : 14:01:04
What the heck is goldmine ?

- Jeff
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-09-20 : 14:04:00
It's a hole in the ground where you find gold silly



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam
Go to Top of Page

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..
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-09-20 : 18:10:00
So is goldmine running on MS SQL Server ?


KH

Go to Top of Page
   

- Advertisement -