The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss ADO specific questions for use with SalesLogix. View the code of conduct for posting guidelines.
|
|
|
|
Date time
Posted: 20 Jul 07 9:13 AM
|
I am trying to pass date in Query but i get error like cannot convert varchar to date. strSQL = "StoreProc '1','HOME','1436.N.Fairmount','Wichita', 'KS','67208', '" & CDate(01/01/2007) & "' " Can you please suggest me how to do this. |
|
|
|
Re: Date time
Posted: 20 Jul 07 10:19 AM
|
Change the date before hand to text, and then pass the text in a variable (instead of as a function) |
|
|
|
Re: Date time
Posted: 23 Jul 07 5:57 AM
|
I have written a small utility that rearranges dates into an SQL useable format...
function RearrangeDate(theDATE) as String
RearrangeDate = ""
if theDATE <> "" then RearrangeDate = Month(theDATE) & "/" & Day(theDATE) & "/" & Year(theDATE) else RearrangeDate = "" End if
end function
As such you can pass a date object directly to it and it will return a string that is useable in SQL. With your code from above you should be able to call it with...
strSQL = "StoreProc '1','HOME','1436.N.Fairmount','Wichita', 'KS','67208', '" & RearrangeDate(Now) & "' "
Which should work for 'todays' date.
I might have the wrong end of the stick with what you are trying to achieve, but give it a go. |
|
|
|
Re: Date time
Posted: 24 Jul 07 3:05 PM
|
I dont use SPROCS with SLX, but I think your problem is much simpler than that - you need to put your date within quotes for the CDATE function: CDATE("01/01/2007").
Timmus |
|
|
|
Re: Date time
Posted: 28 Jul 07 8:32 AM
|
The quotation marks recommendation may have done it, but I think it may be even simpler than that - just don't use the CDate function - pass the date directly in. If you are grabbing a date from a variable, you can do what I do, which is use the "FormatDateTime(theDateVariable, 2)" function. |
|
|
|
Re: Date time
Posted: 12 Sep 07 12:59 AM
|
Originally posted by smriti
I am trying to pass date in Query but i get error like cannot convert varchar to date. strSQL = "StoreProc '1','HOME','1436.N.Fairmount','Wichita', 'KS','67208', '" & CDate(01/01/2007) & "' " Can you please suggest me how to do this. |
|
I know I am late on the game on this one, but did you all notice that the code above is placing single quotes around the result from CDate? That means that strSQL probably looked something like this: "StoreProc '1','HOME','1436.N.Fairmount','Wichita', 'KS','67208', '254545' " Which probably wasn't what was needed, I think that all that was needed here was to get rid of CDate so that strSQL resulted in: "StoreProc '1','HOME','1436.N.Fairmount','Wichita', 'KS','67208', '01/01/2007' "
Again, I know I am late to the game here, but I didn't want to let it pass unnoticed
|
|
|
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|