PostgresDate to Date
AMBIENTE1 opened this issue · 2 comments
AMBIENTE1 commented
Hello pitfield,
please what is the correct solution if I want to store column type date() to Date?
for row in cursor {
let columns = try row.get().columns
let xrow_date = try columns[0].date()
saveData( ucetnidatum: xrow_date ) error: Cannot convert value of type 'PostgresDate' to expected argument type 'Date'
}
func saveDate(ucetnidatum: Date) {
…
}
I need to store the date type value in the Core data.
pitfield commented
Call date(in:)
on the value returned by PostgresValue.date()
. For example:
let xrow_date = try columns[0].date() // xrow_date is of type PostgresDate
let d = xrow_date.date(in: utcTimeZone) // d is a Foundation Date
AMBIENTE1 commented
Yes., Thank you! :)