Banderson
(Brandon Anderson)
January 5, 2018, 2:56pm
1
I’ve tried searching, but I’m sure my problem is so basic that no-one really answers the specific question I’m asking. I’m working on sending out an E-mail via BPM and I am grabbing the ReqDueDate from the job head table. If I just grab that date and put it in the e-mail it looks like this.
what I would like it 12-19-2017
So I figured I would create a variable in the data directive that converts the date to a different format. I found the conversion x.ToString(format) in the GUI. Looks like it should work, I grab the field and try to use the conversion and I get an error. Shown below.
All of the examples I can find online just show something like this
I don’t understand what argument I’m missing.
Banderson
(Brandon Anderson)
January 5, 2018, 3:48pm
2
well @rapat_mark had the answer
Did you try:
ttJobHeadRow.ReqDueDate.Value.ToString(“MM-dd-yyy”)
2 Likes
bmgarver
(Brian Garver)
January 5, 2018, 3:51pm
3
Just a stab…
convert(datetime, ttJobHeadRow.ReqDueDate, 101)
Banderson
(Brandon Anderson)
January 5, 2018, 4:16pm
4
That’s SQL isn’t it? This is C# (it’s in a BPM)
mathis1337
(Aaron Mathis)
January 5, 2018, 4:38pm
5
You can just do a .ToString formate. so at the end add
I added the date below just so you can see how it is used. The .Replace is what removed the / and adds the - how you want above.
var date = DateTime.Now;
date.ToString(“d”).Replace("/","-");
Outputs:
1-5-2018
Obviously use your variable you have above. the var date is just to show you how the .toString should be used. You will use your RequestDate String.
utaylor
(Utah Taylor)
January 5, 2018, 7:37pm
6
DateTime.Now.Date will get you the short date I’m pretty sure. @mathis1337
mathis1337
(Aaron Mathis)
January 12, 2018, 4:14pm
7
Yes but he wanted - and not / which is what that returned. SO you have to do that anyways.
Banderson
(Brandon Anderson)
January 12, 2018, 4:34pm
8
I wasn’t looking for the date that the e-mail was created. I was looking to reformat the required by date. So datetime.Now.Date doesn’t help me.
utaylor
(Utah Taylor)
January 12, 2018, 4:35pm
9
@mathis1337 and @Banderson I should have read the question more carefully. Cheers!
From what I can see, the following two lines produce the same results:
ttJobHeadRow.ReqDueDate.Value.ToString("MM/dd/yyyy");
string.Format("{0:d}", ttJobHeadRow.ReqDueDate);
1 Like