aligredo

aligredo

Hello there, I have table with a field :dayTime, :utc_datetime and I use Timex to convert the string that I take to a datetime, for example I have a string "29/02/2016 22:55:00" I parse it to ~U[2016-02-29 22:25:00Z] after doing some work then passing it to Timex.parse/2. My problem is when I try to create a new instance and save it to the database I get this error

errors: [dayTime: {"is invalid", [type: :utc_datetime, validation: :cast]}],
   data: #App.Context.Schema
   valid?: false

what am I doing wrong?

Thanks in advance.

Showing Posts 1 to 2

mindok

mindok

Hi @aligredo,

Could you show an example of breaking code with:

  1. Your schema code
  2. Your changeset code
  3. The migration to create the tables in the database

Also let us know what version of Ecto & related projects (i.e. ecto_sql & postgrex) you are using (maybe just put the contents of mix.exs up).

Also, I note that the date you supply is 29th Feb 2016 which is valid because 2016 was a leap year. Out of interest, have you tried a different date just to help try to isolate the problem. There may be some date validation bug lurking in there, although I followed the code down to the days in month check for 2016 and it seems ok:

iex> Calendar.ISO.days_in_month(2016, 2)
29

FWIW - I have utc_datetime datatypes working fine

aligredo

aligredo OP

turns out that I was doing something wrong after conversion that caused that error, I fixed it.
Thank you for your time <3

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
widianto
I think I’ve found a small improvement I could contribute to &lt;%= web_namespace %&gt;.CoreComponents (installer/templates/phx_web/compo...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews