Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


process for a date between two dates

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,59562
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> process for a date between two dates
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 process for a date between two dates - 4/28/2008 12:49:03 AM   
  garfunkal

 

Posts: 25
Score: 0
Joined: 3/5/2008
Status: offline
hiya

I am trying to run the code below - the do while loop is meant to pick up a load of entried for a calendar and do some processing when the dates are within a range- for now i am content to just run when they match a date - trying to walk before i run....

anyway - i get a type mismatch error -(type mismatch: 'formatdatetime')

Any ideas?  will i be able to run this for a range, as i intend?


set oNotes = createobject("Notes.NotesSession")
set db = oNotes.GetDatabase("GBLLIV16/SERVER/Royalsun", "mail\hxbostock.nsf")
if db is nothing then
msgbox wscript.Error
else
Set view = db.GETVIEW("Calendar")

Set doc = view.GetFirstDocument
Do While Not doc Is Nothing

Set item = doc.GetFirstItem( "Subject" )
Set start = doc.GetFirstItem( "STARTDATETIME" )

startdate =  cdate(formatdatetime(start.text, vbShortDate))
rangestart  = datevalue("09/05/2007")
rangeend = datevalue("01/04/2007")
if  startdate = rangestart then
msgbox item.text   & " " &  start.text
end if
Set doc  = view.GetNextDocument (doc)
loop
end if
msgbox "done"
 
 
Post #: 1
 
 RE: process for a date between two dates - 4/28/2008 12:57:56 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
What do you get if you MsgBox the value of start.text?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to garfunkal)
 
 
Post #: 2
 
 RE: process for a date between two dates - 4/28/2008 1:02:30 AM   
  garfunkal

 

Posts: 25
Score: 0
Joined: 3/5/2008
Status: offline
if i msgbox it i get 13/10/2005 11:00:00

I wanted to get the appointments (initally) for the whole day, so i stripped out the time segment.

I also checked that they were comazprable dates (both came back as true with isdate).


(in reply to ebgreen)
 
 
Post #: 3
 
 RE: process for a date between two dates - 4/28/2008 1:06:36 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
What about if you MsgBox VarType(start.text)

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to garfunkal)
 
 
Post #: 4
 
 RE: process for a date between two dates - 4/28/2008 1:10:12 AM   
  garfunkal

 

Posts: 25
Score: 0
Joined: 3/5/2008
Status: offline
var type returns 8

(in reply to ebgreen)
 
 
Post #: 5
 
 RE: process for a date between two dates - 4/28/2008 1:16:28 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Well I'm rapidly running out of ideas here. When I take your date and run the same code against it I get a result just fine. Try this:

startdate =  cdate(formatdatetime(CStr(start.text), vbShortDate))


There is no reason that it should matter, but who knows.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to garfunkal)
 
 
Post #: 6
 
 RE: process for a date between two dates - 4/28/2008 1:22:16 AM   
  garfunkal

 

Posts: 25
Score: 0
Joined: 3/5/2008
Status: offline
no luck!

Is it possible that it may not always be the as a date?

for example i just tried to datepart it and compare the string, so effectively it was "mmyyyy", (code as below)

It returned  type mismatch: '[string: "09/06/2006 09:15:00;"]'


set oNotes = createobject("Notes.NotesSession")
set db = oNotes.GetDatabase("GBLLIV16/SERVER/Royalsun", "mail\azmaton.nsf")
if db is nothing then
msgbox wscript.Error
else
Set view = db.GETVIEW("Calendar")

Set doc = view.GetFirstDocument
Do While Not doc Is Nothing

Set item = doc.GetFirstItem( "Subject" )
Set start = doc.GetFirstItem( "STARTDATETIME" )

startdateMMYYYY =  datepart("m",start.text) & datepart("yyyy",start.text)
rangestart  = "042007"
rangeend = datevalue("01/04/2007")

if  startdateMMYYYY = rangestart then
msgbox item.text   & " " &  start.text
end if
Set doc  = view.GetNextDocument (doc)
loop
end if
msgbox "done"


(in reply to ebgreen)
 
 
Post #: 7
 
 RE: process for a date between two dates - 4/28/2008 1:38:55 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
It returned  type mismatch: '[string: "09/06/2006 09:15:00;"]'


Does the string really have a ; on the end? If it does, that would break it.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to garfunkal)
 
 
Post #: 8
 
 RE: process for a date between two dates - 4/28/2008 1:44:19 AM   
  garfunkal

 

Posts: 25
Score: 0
Joined: 3/5/2008
Status: offline
it really has a ; at the end, yes....

i cant for the life of me find out why!


(in reply to ebgreen)
 
 
Post #: 9
 
 RE: process for a date between two dates - 4/28/2008 1:45:43 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Then get rid of the ; and you are good to go.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to garfunkal)
 
 
Post #: 10
 
 RE: process for a date between two dates - 4/28/2008 2:10:08 AM   
  garfunkal

 

Posts: 25
Score: 0
Joined: 3/5/2008
Status: offline
i am sure its well dodge to do this but i have taken the left most 10 characters........

cheers for the help - excellent.


----------------------------------
Do While Not doc Is Nothing

Set item = doc.GetFirstItem( "Subject" )
Set start = doc.GetFirstItem( "STARTDATETIME" )

startdatecut = datevalue(left(start.text,10))
startdate = datevalue(startdatecut)

rangestart  = datevalue("03/05/2008")
rangeend = datevalue("05/05/2008")
if  startdate =>  rangestart  then
if startdate =< rangeend then
msgbox item.text   & " " &  start.text
end if
end if
Set doc  = view.GetNextDocument (doc)
loop

(in reply to ebgreen)
 
 
Post #: 11
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> process for a date between two dates Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts