How does SalesLogix want a date string formatted to be converted into a Data Type???

Question:

How does Saleslogix want a date string 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”)

Answer:

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

Submit a Comment

Your email address will not be published.

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!