Date part of a DateTime field for comparison

514 views Asked by At

I'm using Superlist with a due date column (SQL DateTime) as a column in dd/mm/yyyy format.

I need, in order to the final user be able to sort by this column, to use just the DATE part of the column. The problem is that if I set the DueDate.Date value, it shows the time as 00:00:00, and if I set as DueDate.ToShortDateString() the issue is that February 1st happens before January 31 in the ascending order.

Is there ANY way to show just the date without converting it as a string?

2

There are 2 answers

1
AudioBubble On BEST ANSWER

You are confusing the idea of a structure and a string. When you say "Show Date", you are talking about interpreting the DateTime struct as a string...for your viewing.

So the answer to your question is no, there is no way to show anything about a DateTime without converting it first to a string.

If you're talking about retrieving just the date part of the DateTime struct, then what you have described is how it works. Because a Date is really just the DateTime with a zeroed out Time portion.

1
Zach Green On

Shark is correct about the generic question, but to show as a sortable string:

mydate.ToString("yyyy/mm/dd");