Hi All,
I need help passing queue item to Send Calendar Invite activity.
Following is Queue Data-
StartDate: 28 Jan 22
EndDate: 28 Jan 22
CourseTime: 08:00 AM - 01:00 PM
Need to convert StartDate to Date variable in UK format
StartDate (dateTime variable) = DateTime.ParseExact(modifiedDate,“MM/dd/yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”))
returning error cannot assign Date to String
If I convert StartDate = Convert.ToDateTime(DateTime.ParseExact(modifiedDate,“MM/dd/yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”))
Start Date: String was not recognized as a valid DateTime.
I need to pass Start Date, Start Time as seen in screenshot and Duration needs to be Course Time (Start Time minus End Time)
As you mentioned, StartDate (dateTime variable) = DateTime.ParseExact(modifiedDate,“MM/dd/yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”))
In the above variable StartDate, what is the datatype you have set?
You have extra ) in your Expression, I have modified it.
Updated expression: DateTime.ParseExact(modifiedDate,“MM/dd/yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)
Note: Both the variables, modifiedDate & StartDate must be in String datatype because in the expression at the end you have converted the value into string (.ToString(“dd/MM/yyyy”))
I have shared a sample flow, in this I have created two variables:
USDate = “06/15/2020 14:45:43” [Datatype as String]
UKDate = DateTime.ParseExact(USDateTime, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture).toString("dd/MM/yyyy")[Datatype as String]
Start Date - DateTime Variable (dd/MM/yyyy)
Start Time - DateTime Variable (dd/MM/yyyy hh:mm:ss)
Duration - takes only Timespan variable (hh:mm:ss)
In my DataTable I have values as follows
StartDate: 28 Jan 22
EndDate: 28 Jan 22
CourseTime: 08:00 AM - 01:00 PM
In Start Date - need to Enter 28/01/2022
In Start Time - need to enter 28/01/2022 08:00:00 (i.e 8 AM meeting start time)
in Duration - need to enter total number of hours meeting will last (i.e. 00:00:30)
1st requirement. - Enter Start Date in UK format.
Convert StartDate: 28 Jan 22 into DateTime Variable and pass value in UK Date Format.
2nd requirement - Enter Start Time (Start Date + Start Time) in dd/MM/yyyy hh:mm:ss
Concatenate Start Date with Time span from Duration, make DateTime Variable and pass
3rd Requirement - Duration 8 am to 1 PM is 5 hours.
Create a TimeSpan variable and pass this 5 hours in that field.
Just replace the variable accordingly with your excel value.
Steps:
Assign the USDate value into a variable. (USDate variable which I have implemented in the workflow).
Assign UKDate = DateTime.ParseExact(USDateTime, "dd MMM yy", System.Globalization.CultureInfo.InvariantCulture).toString("dd/MM/yyyy") [which holds the US format converted to UK Format value in the workflow]
Now, since the Time value comes in a single string variable, we need to split them to get start time and end time into a separate variable. I have stored the Time value into a variable called (CourseTime)
Assign StartTime = CourseTime.Split("-"c).First.ToString [holds the value 08:00 AM]
3.2 Assign EndTime = CourseTime.Split("-"c).Last.ToString [holds the value 01:00 PM]
Assign TimeDiffValue = DateDiff(DateInterval.Hour,Convert.ToDateTime(StartTime),Convert.ToDateTime(EndTime)).ToString [holds the difference value which is 5]
To join Start Date + Start Time: StartDate + " " + StartTime
I hope your issue would be sorted out.
Regards, @90s_Developer