Geetika Malik
June 29th, 2001, 04:38 AM
Dim dteValue as date
dteValue=date
"SELECT CODE FROM PLAN WHERE
(DATEVALUE(""" dteValue """) BETWEEN
[StartDate] AND [EndDate])"
This query gives me all the codes in which Today's Date falls between their StartDate and EndDate.
Now, i have two more fields [StartTime] and [EndTime]. So, I want to write a query that gives me all the codes in which Today's Date including Time falls between their StartDate + StartTime and EndDate + EndTime.
I have to write this query for MS Access, in Visual Basic.
The query I have written is as follows:
Dim sDate as string
sDate=dteToday & FORMAT(time,hh:mm)
"SELECT CODE FROM PLAN WHERE
(DateValue(""" & sDate & """)] BETWEEN
[StartDate] & [StartTime] AND
[EndDate] & [EndTime])"
The above query works but does not give right value because DateValue function excludes the Time part from Date. So, Please suggest the function which solves
the purpose or
another way of writing this.
Thanks
dteValue=date
"SELECT CODE FROM PLAN WHERE
(DATEVALUE(""" dteValue """) BETWEEN
[StartDate] AND [EndDate])"
This query gives me all the codes in which Today's Date falls between their StartDate and EndDate.
Now, i have two more fields [StartTime] and [EndTime]. So, I want to write a query that gives me all the codes in which Today's Date including Time falls between their StartDate + StartTime and EndDate + EndTime.
I have to write this query for MS Access, in Visual Basic.
The query I have written is as follows:
Dim sDate as string
sDate=dteToday & FORMAT(time,hh:mm)
"SELECT CODE FROM PLAN WHERE
(DateValue(""" & sDate & """)] BETWEEN
[StartDate] & [StartTime] AND
[EndDate] & [EndTime])"
The above query works but does not give right value because DateValue function excludes the Time part from Date. So, Please suggest the function which solves
the purpose or
another way of writing this.
Thanks