Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

SSRS Sort by Date goes from 31/01/2018 to 01/01/2019 instead of 01/02/2018

Posted on by Microsoft Employee

Hello friends,

I've created a report for our events team that organises all their service calendar bookings by date for the whole year. The table is currently sorting on Scheduledstart field which returns as mm/dd/yyyy hh:mm, such as 1/23/2018 14:00, which up til now has been fine (i changed the number format of the column to just be date in the UK format, 23/1/2018.

However, now that they are putting in bookings for 2019, the sorting jumps from 31/01/2018 to showing bookings from 01/01/2019. It's as though it doesn't recognise it as a date/time that is a year later and rather one number/character increased. I'm not sure how to get this value to operate as a date, perhaps something in the SQL command for the dataset?

The question is how do we get this show chronologically and go to February 2018, only going to January 2019 after the end of December 2018?

Many thanks in advance!

*This post is locked for comments

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: SSRS Sort by Date goes from 31/01/2018 to 01/01/2019 instead of 01/02/2018

    If your data is in string format, you can use the CONVERT function in SQL to convert into from a string value into a numeric value. You can also convert it within your SSRS report as a calculate field.

    You can use something like this to sort:

    SELECT new_invoicedate FROM Filterednew_Invoice

    ORDER BY convert(nvarchar(10), new_invoicedate, 111) ASC

    Take a look at the following link for formats that you can use for sorting and decide which one will work for you:

    www.sqlinfo.net/.../sql_server_SELECT-Formatting_Date_Time.php

    Hope this helps.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: SSRS Sort by Date goes from 31/01/2018 to 01/01/2019 instead of 01/02/2018

    Hi David,

    Thanks for chipping in! This is a SQL pulled dataset, is it possible to get this functionality with SQL?

  • David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: SSRS Sort by Date goes from 31/01/2018 to 01/01/2019 instead of 01/02/2018

    Is this a SQL or Fetch-based report ? If it's a Fetch-based report, you'll get 2 fields that represent each DateTime field - for Scheduledstart you'd get:

    • Scheduledstart - this will be a text field
    • ScheduledstartValue - this will be a datetime field

    To get the sorting you want, you'll need to sort by the datetime field - i.e. ScheduledstartValue

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans