Brezhnews
Brezhnews

Reputation: 1569

Format date on insert in mysql

I am trying to insert date in table in format DD.MM.YYYY, How do I do it?
Here is the code what I am trying, but there are some errors in it:

insert into nol_art_izm([ART_ID], [DAT])
    select distinct
        a.ID, DATE_FORMAT({fn now()},'%d.%c.%Y')
    from
        openxml(@hDoc, '/art_komp/nol_art') with #artTMPL xd
        join nol_art a on xd.cd = a.cd


Edit
Answer
Solved it by myself. I am inserting in DAT column with now(), but I am formatting my view column like I needed.

Upvotes: 2

Views: 329

Answers (2)

keyser
keyser

Reputation: 19189

edit:

Mysql has functions to change format. I found:

str_to_date('".$mydate."', '%d-%c-%Y')

Upvotes: 0

Roman
Roman

Reputation: 3843

this should work:

DATE_FORMAT(now(),'%d.%m.%Y')

Upvotes: 2

Related Questions