Explanation of a snippet of code please?

  • Thread starter Thread starter Matthew Gonzalez
  • Start date Start date
M

Matthew Gonzalez

I copied some code off this web page:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnout2k/html/oldaysappts.asp

Here is the snippet I copied:

' Specify the range.
strToday = "[Start] >= '" & strTheDay & _
"' and [Start] < '" & strTheDay & " 11:59 pm'"


I know what the code is effectively doing, but could someone break down
the syntax for me? I haven't had any luck finding this anywhere online.
strToday and strTheDay are string variables, but what is the

"[Start] >= '"

thing doing? What is [Start]? What is the single quote doing?

Thanks.




Matthew Gonzalez
 
Hi Matthew,

"Start" is the field name your are looking for. it´s probably the start
date of an AppointmentItem.

Strings in this query need to be enquoted, therefor the single quotas.
For handling Strings, which could self contain a single quote it´s
recommended to use Chr(34) instead.

Start>=strTheDay

means you´re looking for items starting at or after strTheDay.
 
Michael said:
Hi Matthew,

"Start" is the field name your are looking for. it´s probably the start
date of an AppointmentItem.

Strings in this query need to be enquoted, therefor the single quotas.
For handling Strings, which could self contain a single quote it´s
recommended to use Chr(34) instead.

Start>=strTheDay

means you´re looking for items starting at or after strTheDay.

Thanks, so that same snippet now looks to me like it is filling the same
field [Start] with two different things. Unless it is saying:

Start>=(why not just = here?)strTheDay but before 11:59pm on strTheDay

Is that a correct pseudo code interpretation?

Thanks.



Matthew
 
strToday = "[Start] >= '" & strTheDay & _
"' and [Start] < '" & strTheDay & " 11:59 pm'"

In your first statement a time is missing. It should be:

strToday = "[Start]>='" & strDate & " 00:01 am' and " & _
"[Start]<='" & strDate & " 11:59 pm'"

In pseudo: Start between beginning and end of day.


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook



Matthew said:
Michael said:
Hi Matthew,

"Start" is the field name your are looking for. it´s probably the
start date of an AppointmentItem.

Strings in this query need to be enquoted, therefor the single
quotas. For handling Strings, which could self contain a single
quote it´s recommended to use Chr(34) instead.

Start>=strTheDay

means you´re looking for items starting at or after strTheDay.

Thanks, so that same snippet now looks to me like it is filling the
same field [Start] with two different things. Unless it is saying:

Start>=(why not just = here?)strTheDay but before 11:59pm on strTheDay

Is that a correct pseudo code interpretation?

Thanks.



Matthew
 
Michael said:
strToday = "[Start] >= '" & strTheDay & _
"' and [Start] < '" & strTheDay & " 11:59 pm'"


In your first statement a time is missing. It should be:

strToday = "[Start]>='" & strDate & " 00:01 am' and " & _
"[Start]<='" & strDate & " 11:59 pm'"

In pseudo: Start between beginning and end of day.


Aaaahhhh, I get it. It's essentially serving as an IF statement then
(in my code):

If the [Start] field is between these times then include it.


It must default to the beginning of the day if not fed a time or
something. Thank you much.




Matthew
 
Back
Top