-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
TL;DR: Is the SQLite Date function supported? If so, what is the return type?
[sqlite-pcl-net 1.9.172 and .NET 9]
I am attempting to retrieve a list of distinct DateOnly objects. I am aware that DateOnly is not currently supported and so I was hoping to return another type that could be parsed to DateOnly, for example, string.
However, I notice that when using the DATE() function, the returned list is of default values. According to the SQSLite docs:
The date() function returns the date as text in this format: YYYY-MM-DD.
I assume then that this should be parsable to a string, or am I missing something?
Example
public class Task
{
[PrimaryKey] public string Id { get; init; } = Guid.NewGuid().ToString();
public DateTime DueAt { get; set; } = DateTime.Now;
}public class DueDateWrapper
{
[Column("DueDate")]
public string DueDate { get; set; } = string.Empty; // N.B.: neither string, int, or DateTime work
}
public async Task<List<DateOnly>> GetUniqueDueDatesAsync(){
var dueDates = await Database.QueryAsync<DueDateWrapper>(
"SELECT DATE(DueAt) AS DueDate FROM Task"
);
// ...
}Output is a list of empty strings. However, removing DATE as follows correctly returns a list of ticks as strings:
var dueDates = await Database.QueryAsync<DueDateWrapper>(
"SELECT DueAt AS DueDate FROM Task"
);Metadata
Metadata
Assignees
Labels
No labels