Convert from string to date using Export Outlook

Hello everyone,

I have two variables named TodayDate and YesterdayDate declared like in the following image:



I want to add this variables in the Export to Datatable activity
image
but the error says: Compiler errors encountered processing expression "YesterdayDate".Option Strict On disallows implicit conversions from 'String' to 'Date' As per I understand I should convert the TodayDate and YesterdayDate in Date format. Any idea how to do that?

Hi,

You can use
DateTime.ParseExact(variablename,“dd-MM-yyyy”,System.Globalization.CultureInfo.InvariantCulture)

syntax to convert string to datetime.

Thanks,
Bhagyashri

HI @Xheni_Xhensila

How about this expression?

DateTime.ParseExact(Now.Tostring,"dd-MM-yyyy hh:mm:ss",System.Globalization.CultureInfo.InvariantCulture).Tostring("yyyyMMdd")

Regards
Gokul

Hey!

Try this:

Assign strToday = Now.ToString("yyyyMMdd")
Assign strYesturday = Now.AddDays(-1).ToString("yyyyMMdd")

Try this and let me know

Regards,
NaNi

Update Expression @Xheni_Xhensila

Assign TodayDate = DateTime.Now.ToString
Assign YesterdayDate = DateTime.Now.AddDays(-1).ToString
DateTime.ParseExact(TodayDate,"MM/dd/yyyy HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture).Tostring("yyyyMMdd")
DateTime.ParseExact(YesterdayDate,"MM/dd/yyyy HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture).Tostring("yyyyMMdd")

For Reference

Date Expressions.xaml (6.4 KB)

Regards
Gokul

still giving errors becasue as I mentioned before I need to use it in the Export Activity which accepts only Date in the format yyyy,MM,dd

Note: Before to use YesterdayDate and TodayDate the values in Export activity were replaced with static information 2022,12,01 and 2023,12,30

image
it was like this before and it used to work perfectly But I need to replace the From with YesterdayDate and Till with TodayDate

Hello @Xheni_Xhensila

I think you can use Modify Date activity.

Please watch the below video. It can help to resolve your issue.

uhmmm so interesting, Thank you for sharing. I already fixed. Date.ParseExact(YesterdayDate,“yyyyMMdd”, System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy,MM,dd”)

yes, you can do it like using the expression as well… :+1:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.