|
-
Sep 20th, 2002, 05:55 AM
#1
Database dates (Access and SQL Server)
Ok, I have a date field in my Database, Modified_Date, which stores the date as 27/08/02 13:57:55.
If I wanted to select anything that had been changed since I last loaded, ie anything greater than 27/08/02 13:57:55 what would my SQL SELECT statement look like?
Code:
SELECT *
FROM tblTable
WHERE Modified_Date > This is the bit I can't work out...:(
I really should know it, but can't quite get it to work...
Anyone...
Call myself a pro VB Developer...*SIGH* Bad Woka *SLAP*
-
Sep 20th, 2002, 06:20 AM
#2
My suggestion would be to place two textboxs on your screen (start/end date).
Then, code a BETWEEN in your SQL query to look for records that fall between those input dates.
-
Sep 20th, 2002, 06:21 AM
#3
well how would you know the last date since last loaded? when you do load the data.. do you store that date/time anywhere to do the compare with?
-
Sep 20th, 2002, 06:24 AM
#4
A SELECT MAX(datemodified) should give you the latest modification date.
No?
-
Sep 20th, 2002, 06:27 AM
#5
Frenzied Member
WhoeHaHaHaHa me helping the pro
Should i
ok try this
VB Code:
"SELECT *
FROM tblTable
WHERE Modified_Date >= #" & Format(start, "dd/mm/yy hh:mm:ss") & "#"
This is if u are sure it is stored in that format.
[EDIT]
You know start is a variable with a date in it
[/EDIT]
Last edited by swatty; Sep 20th, 2002 at 06:34 AM.
Code:
If Question = Incomplete Then
AnswerNextOne
Else
ReplyIfKnown
End If
cu Swatty
-
Sep 20th, 2002, 06:28 AM
#6
Originally posted by Hack
A SELECT MAX(datemodified) should give you the latest modification date.
No?
thats what i was thinking... but if you then did
select * from table where Modified_Date > "THE SELECT MAX VALUE"
you won't get any data.. because no Modified_Date will be greater than the max you just pulled...
-
Sep 20th, 2002, 06:29 AM
#7
SELECT *
FROM tblTable
WHERE Modified_Date > '2002/08/27 13:57:55'
If you specify the date in ISO 8601 format, both Access as SQL server should understand it. I'm not sure if Access 97 and earlier can understand the single quote, maybe you need the # sign instead.
EDIT: This is the way if the field is a Date field. The way the date is displayed has nothing to do with the way it is stored. If you used a text field, you have a problem.
-
Sep 20th, 2002, 06:34 AM
#8
Originally posted by Kleinma
thats what i was thinking... but if you then did
select * from table where Modified_Date > "THE SELECT MAX VALUE"
you won't get any data.. because no Modified_Date will be greater than the max you just pulled...
Righto...so it seems that two queries might be the answer. The first would get the last modified date, store it into a variable, which could be used in the second query.
-
Sep 20th, 2002, 06:35 AM
#9
Originally posted by Frans C
SELECT *
FROM tblTable
WHERE Modified_Date > '2002/08/27 13:57:55'
If you specify the date in ISO 8601 format, both Access as SQL server should understand it. I'm not sure if Access 97 and earlier can understand the single quote, maybe you need the # sign instead.
EDIT: This is the way if the field is a Date field. The way the date is displayed has nothing to do with the way it is stored. If you used a text field, you have a problem.
is this all he wanted??? man if so I think the rest of us were looking at the problem a little to hard...
I guess woka just wanted syntax
-
Sep 20th, 2002, 06:35 AM
#10
-
Sep 20th, 2002, 06:37 AM
#11
Re: Slime on a rock makes for a great pudding...
you also have to remember that sql likes ' around a date while access like # around a date...
-
Sep 20th, 2002, 06:38 AM
#12
Circles in the sand implicate cake is on the way...
Which is correct...?
Code:
WHERE Modified_Date > '2002/08/27 13:57:55'
OR
Code:
WHERE Modified_Date > #2002/08/27 13:57:55#
Woka - having a crappy day - widget
-
Sep 20th, 2002, 06:39 AM
#13
Re: Circles in the sand implicate cake is on the way...
Originally posted by Wokawidget
Which is correct...?
Code:
WHERE Modified_Date > '2002/08/27 13:57:55'
OR
Code:
WHERE Modified_Date > #2002/08/27 13:57:55#
Woka - having a crappy day - widget
read my post above this one
-
Sep 20th, 2002, 06:39 AM
#14
U posted that while I was typing 
D'oh!
-
Sep 20th, 2002, 06:42 AM
#15
Tis OK though, coz I would only have to update one function in the 3rd Tier (Data Tier) of my app...
VB Code:
Public Function NormailseDate(ByVal pdteDate As Date) As String
Dim strTemp As String
strTemp = "#" & Format(pdteDate, "mm/dd/yyyy hh:nn:ss") & "#"
NormaliseDate = strTemp
End Function
Woka
-
Sep 20th, 2002, 06:50 AM
#16
Originally posted by Wokawidget
strTemp = "#" & Format(pdteDate, "mm/dd/yyyy hh: nn:ss") & "#"
Woka
WATCH THOSE N's!!!!!!
-
Sep 20th, 2002, 06:53 AM
#17
-
Sep 20th, 2002, 07:01 AM
#18
Frenzied Member
What a day , deffinitly having a nice we to come
Originally posted by kleinma
WATCH THOSE N's!!!!!!
Could it be those were nanoseconds but don't they have to be put after the seconds ???
Which is correct...?
VB Code:
WHERE some_text like 'Woka Woka Woka said packm%'
OR
VB Code:
WHERE some_text like 'Woka Woka Woka said packm*'
All depends on the db your testing against
Code:
If Question = Incomplete Then
AnswerNextOne
Else
ReplyIfKnown
End If
cu Swatty
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
|