web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Date format in date query range

(0) ShareShare
ReportReport
Posted on by 1,673

Hi everyone

I'm running an SSRS report using a dataprovider, but that also has a default query.

On that query, on one of the tables there is a date range that is open, so that when the user opens the report, they can specify a date.

In the data provider, I retrieve the value from the query so that I can display it on the report, reformatted etc.

The way I'm retrieving the parameter is like this:

str dateParm = query.dataSourceTable(tableNum(MyTable)).findRange(fieldNum(MyTable, dateField)).value();

When I print this value to the report though, it always appears in a M/d/yyyy format, but the default date format in the regional settings of the server and client are dd/m/yyyy.

Unfortunately, to retrieve the value from a QueryBuildRange object, you can only use value(), which returns a string. The same functionality is available using the QueryFilter object.

So, here are my questions:

1) Is that the only way to pull the date value our of a dateRange on a query object?

2) Is it possible to format that date while retrieving it?

3) What date format does it use by default? I'd expect it to use the local regional settings but it doesn't; it looks like a US format by default. What format does it use?

4) Is there a better/other way to pull the date value of the range out in the correct format?

Tx

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,967 Most Valuable Professional on at
    1. No, you can't get a date, because the value is a string. But you can convert this string to date, if it's a date. It may be a date range, function (day(-1)) and so on.
    2. No, it's not a date.
    3. There is no reason to respect regional settings, because the value is only for internal queries and not for user interface. You have this problem because you're trying to use it for a purpose which it isn't intended for.
    4. As discussed in 1), you can convert the value to date if it's a date, but there are other value range values than just a date.
  • BrandonSA Profile Picture
    1,673 on at

    Hi Martin

    Thanks for the reply.

    Regarding point 3,  I understand why there is no reason for it to respect regional settings being for internal queries - no problem with that - I just want to make absolutely sure that the format that it does use is constant so that I can deal with it in a standard way. I know it's not the way it should be used, but it is a user requirement for now, so I need to make sure I can format the date properly to print it on the report. Do you know if I can count on the format always being M/d/yyyy, or always being constant?

    Thanks

  • Verified answer
    Martin Dráb Profile Picture
    237,967 Most Valuable Professional on at

    Sorry, I never really paid attention to this implementation detail as long as it works. Now I've looked into xSysQuery::value() and I see Microsoft converts dates to string by simple strFmt('\"%1\"', date), therefore it does take user's regional settings into account at this stage (and kernel converts it to SQL format later) and therefore you'll have to take it into account too when converting the string back to a date.

  • BrandonSA Profile Picture
    1,673 on at

    Hi Martin

    I see that now. Thanks for the answers

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans