Not applicable

formate date - month and day problem

Jump to solution

Hi,

 

I have a list with a column that holds a date.

I run a scheduled site workflow that will loop through the list. As part of the loop I'll use a query list action and read out the date into a work flow variable. This variable is used in a notification mail where I use the inline FormatDate function to present the date as dd-MM-yyyy.

 

My problem is, that the date is actually formatted the other way around.

So 8th of September should come out as 08-09-2014 (day-month-year). But it's formatted as 09-08-2014 (month-day-year).

If I have a date in my list that is 20th of April is should come out as 20-04-2014. But with this date the function fails resulting in an output like

fn-FormateDate(20-04-2014 00:00, dd-MM-yyyy)

It makes sense that it fails if it deals with the date as month = 20 since only 12 months are available.

 

I suspect that the problem comes from reading the date in the query list action. Here the date is read into a workflow variable. I suspect that the day is read as month and month is read as day. But I don't know how to overcome this problem.

 

Any thoughts how to avoid this problem?

0 Kudos
Reply
4 Replies
Not applicable

Re: formate date - month and day problem

Jump to solution

Have you ever tried to output the content of your variable to the history? If yes, what's the content of it? What are the regional settings of your site?

0 Kudos
Reply
Not applicable

Re: formate date - month and day problem

Jump to solution

Hi,

The output is the same in the history list. This is two entries from the log:

01-09-2014 09:25Workflow CommentDate is: 12-08-2014 00:00
Format is: 08-12-2014
Day is: 12/8/2014
Month is: 12
Year is: 2014
01-09-2014 09:25Workflow CommentDate is: 28-08-2014 00:00
Format is: fn-FormatDate(28-08-2014 00:00, dd-MM-yyyy)
Day is: fn-FormatDate(28-08-2014 00:00, d)
Month is: fn-FormatDate(28-08-2014 00:00, MM)
Year is: fn-FormatDate(28-08-2014 00:00, yyyy)

In the first entry the date was entered as 12th of August 2014, but the workflow get is as 8th of August 2014.

In the second entry the date was entered as 28th of August 2014, but the workflow errors because it think of it as 8th of month 28.

0 Kudos
Reply
bhutim
Apprentice

Re: formate date - month and day problem

Jump to solution

Hi Henrik,

 

Have you tried to store the date using the Nintex Date Calculation function instead of using normal variables? I have had this problem before what I did is to store the first date using the Date Calculation function and then I can format the date to any format after that. Since you are using a query list I guess the date you are reading is from a list. My suggestion is:

  • First ensure that your site regional settings is correct - your locale etc;
  • First thing in your loop is set the date variable using calculate date function (see image below);
  • Then set your string variable and use your format date function;

CalculateDate.JPG

CalculateDate1.JPG

Just becareful if there is a chance that your date can be null it's best to use a function to get year out and if year is 0001 you know that date field is empty and you don't do the calculated date function because I believe it fails when there is no date.

 

Good luck.

 

Regards

 

Bhuti

0 Kudos
Reply
Not applicable

Re: formate date - month and day problem

Jump to solution

Hi Henrik Klit Andersen, did Bhuti's suggestion help you?

0 Kudos
Reply