Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Need help with Date Function VBScript

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Need help with Date Function VBScript
  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 >>
 Need help with Date Function VBScript - 6/15/2005 11:44:11 PM   
  Nexis

 

Posts: 5
Score: 0
Joined: 6/15/2005
From:
Status: offline
Hi Guys

Have been unable to solve a ceratin dilemma that has arose. I am currently trying to design a page that brings up a report of work permits that are either about to expire within the next month or have already expired. I just can't seem to get the SQL statement right. I am not getting any errors though, just that it is telling me that there are no records, when I know that there are as I entered them myself.

Please HELP!!!


Here is the statement, The Date_to field is the one that I am obviously making reference to. I have removed any and all input masks, etc.:



"SELECT * FROM WorkPermit WHERE ([Date_to] < "& DateAdd("m", -1, DateSerial(Year(Now()),Month(Now()),Day(Now()))) &");"
 
 
Post #: 1
 
 RE: Need help with Date Function VBScript - 7/11/2005 10:00:43 AM   
  VBS

 

Posts: 110
Score: 0
Joined: 3/2/2005
From: Lebanon
Status: offline
Dear Nexis,
Try using these SQL Statments:

"SELECT * FROM WorkPermit WHERE Date_to<"& DateAdd("m", -1, DateSerial(Year(Now()),Month(Now()),Day(Now()))

"SELECT * FROM WorkPermit WHERE Date_to<"& DateAdd("m", -1, DateSerial(Year(Now()),Month(Now()),Day(Now()))) &");"

"SELECT * FROM WorkPermit WHERE (Date_to<"& DateAdd("m", -1, DateSerial(Year(Now()),Month(Now()),Day(Now()));"

"SELECT * FROM WorkPermit WHERE [Date_to]<"& DateAdd("m", -1, DateSerial(Year(Now()),Month(Now()),Day(Now()))) &";"

"SELECT * FROM WorkPermit WHERE (Date_to<"& DateAdd("m", -1, DateSerial(Year(Now()),Month(Now()),Day(Now()))) &")"

"SELECT * FROM WorkPermit WHERE ([Date_to] < "& DateAdd("m", -1, DateSerial(Year(Now()),Month(Now()),Day(Now()))) &");"

if none had worked try the last one, (and i think that it is the one that should work)

dim DateThing

DateThing=DateAdd("m", -1, DateSerial(Year(Now()),Month(Now()),Day(Now())))

"SELECT * FROM WorkPermit WHERE [Date_to]<"& DateThing &";"

"SELECT * FROM WorkPermit WHERE (Date_to<"& DateThing &")"

"SELECT * FROM WorkPermit WHERE (Date_to<"& DateThing &");"

"SELECT * FROM WorkPermit WHERE Date_to<"& DateThing

or

"SELECT * FROM WorkPermit WHERE [Date_to]<'"& DateThing &"';"

"SELECT * FROM WorkPermit WHERE (Date_to<"'& DateThing &"')"

"SELECT * FROM WorkPermit WHERE (Date_to<'"& DateThing &"');"

"SELECT * FROM WorkPermit WHERE Date_to<'"& DateThing & "'"


I hope this helps u

Best Regards

Firas S Assaad


_____________________________

Anything in VB or VBScript or ASP email me or IM on firas489@hotmail.com or firas489@gmail.com

(in reply to Nexis)
 
 
Post #: 2
 
 RE: Need help with Date Function VBScript - 7/12/2005 1:52:20 PM   
  vietnamblood

 

Posts: 14
Score: 0
Joined: 3/28/2005
From:
Status: offline
i agree with VBS

(in reply to VBS)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Need help with Date Function VBScript 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