Remove the time from DateTime in BPM widget

,

10.2.300.24
I am using the “Set Argument/Variable” widget in a BPM Workflow.
My working C# code to get the PO Created Date is this:

Db.POHeader.FirstOrDefault(p => p.Company == ttRcvHeadRow.Company && p.PONum == ttRcvHeadRow.PONum)?.OrderDate

BUT, it is DateTime.
The results in my email widget are :
PO created date: 9/10/2019 12:00:00 AM

I don’t know how to convert this to just date.
I’ve tried what Google has shown - adding “.date” at the end, or adding “.ToString(“yyyy-MM-dd”)” at the end. These generate errors when checking syntax.

Does anyone know what I’m looking for?
Ben

where are you trying to format this? Your code snippet doesn’t show that. You can’t format withing the linq expression, you’d have to do it afterwards.

The “Set Argument/Variable” is referenced in my Email Template:

image

“DateTime” was the date choice in the Variable area:

You could create another variable POIssueDate_str, of type Sting, and set it after setting the POIssueDate variable.

POIssueDate_str = POIssueDate.ToShortDateString();

Then reference the string one in your field

This is my attempt to follow your suggestion:

POIssueDate.Value.ToString(“MM-dd-yyyy”)

This worked!
Thanks Guys!

1 Like

Hi Team,
I have the same exact issue I have an email alert displaying the PORelRow.PromiseDt field and it comes over as datetime instead of date. I tried to follow the example above and to be honest I’m a bit lost. Not exactly sure how you guys were able to resolve it.

1 Like

I hate setting my own answer as the Solution. How I arrived there was Calvin.

Adding a second variable that I could set to String:

Hi Ben,
Thanks for the response, what are you using as condition statements? I have about 30+ different email alerts and that could use this quick fix as well. So your help is much appreciated. Can you potentiality have a step by step instructions?

again thanks in advance.

Adrian

I think you’re getting that error due to the semi-colon within the editor window. Take that out and you should be good to go (or get a different error at least. :slight_smile: )

Hi Mark,
I got it figured out. for shame on my part.

Thanks everyone for your help. Now have the tools to set up the remaining email alerts. Pasted below is my working solution.

image