8/29/2025 11:32:55 AM
|
|
slxdeveloper.com Community Forums |
|
|
|
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 writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
|
|
|
|
Convert String to Date
Posted: 19 Aug 09 11:20 AM
|
Hello everyone, I'm sure this is a very simple question but I am having a hard time finding how Saleslogix wants a date formatted. I am getting a date from a user with a DateTimeEdit control then attempting to create an activity for the next month.
I think it will work once I figure out how Saleslogix wants the Date string formatted to be converted into a Date type.
Here is what I have so far: Sub DateTimeEdit1Change(Sender) Dim Act Dim SlashPos Dim strDate Dim strMonth Dim newMonth Dim dateRight Dim newDate Dim strLen strDate = DateTimeEdit1.DateTime slashPos = InStr(strDate,"/") strMonth = Left(strDate, (slashPos - 1)) newMonth = strMonth + 1 strLen = Len(strDate) dateRight = Right(strDate, (strLen - slashpos)) newDate = newMonth & "/" & dateRight & "12:00:00" Set Act = Application.Activities.Add(atPhoneCall) Act.AccountID = Application.BasicFunctions.CurrentAccountID Act.AccountName = Application.BasicFunctions.CurrentAccountName Act.StartTime = newDate Act.OpportunityID = Application.BasicFunctions.CurrentOpportunityID Act.Alarm = 1 Act.AlarmTime = newDate Act.Category = "Order Final Documents" Act.Title = "Order Final Documents" Act.Save MsgBox("Activity Saved")
Thanks, Andrew
|
|
|
|
Re: Convert String to Date
Posted: 19 Aug 09 11:59 AM
|
Use CDate to convert the date. If you need to add a Month it may be easier to do so as a a Date as well (see sample function below)
Dim strDate Dim dt
strDate = "01/06/2009 12:15:00" dt = CDate(strDate)
'Add a Single Day dt = CDate(CDbl(dt) + 1) msgbox dt ' Will show 1/7/2009 'Add a Month dt = AddMonth(dt) msgbox dt ' Will show 2/7/2009
Function AddMonth(dt) Dim m Dim y m = Month(dt) y = Year(dt) Select Case m Case 1, 3, 5, 7, 8, 10, 12: dt = CDate(CDbl(dt) + 31) Case 2: if (y Mod 4) = 0 then dt = CDate(CDbl(dt) + 29) Else dt = CDate(CDbl(dt) + 28) End If Case 4, 6, 9, 11: dt = CDate(CDbl(dt) + 30) End Select AddMonth = dt End Function |
|
|
|
Re: Convert String to Date
Posted: 19 Aug 09 12:33 PM
|
Raul, Thank you! That works perfectly. Awesome how it considers different number of days in a month.
Andrew |
|
|
|
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!
|
|
|
|
|
|
|
|