Connecting Tech Pros Worldwide Help | Site Map

how to insert the date in specified format

Newbie
 
Join Date: Oct 2007
Location: Hyderabad
Posts: 29
#1: Jul 30 '09
Hi!

I would like to insert the date in specified format in DB, the date type is Date Type, I am using the following queries to insert the data

1) INSERT INTO EMP VALUES
(1, 'red', 'CLERK', 2,
date(date_format('17-DEC-1980', '%d-%b-%Y')), 800, NULL, 20)

2)INSERT INTO EMP VALUES
(1, 'red', 'CLERK', 2,
date_format('17-DEC-1980', '%d-%b-%Y'), 800, NULL, 20);


I tried to use both queries but throwing error as

Script line: 1 Truncated incorrect datetime value: '17-DEC-1980'
Script line: 5 Truncated incorrect datetime value: '20-FEB-1981'

cant we insert the date in specified format in DB.

Thanks

Sreenath
mwasif's Avatar
Moderator
 
Join Date: Jul 2006
Location: Pakistan
Posts: 718
#2: Jul 30 '09

re: how to insert the date in specified format


You can not insert date in the specified format. You can only insert date in yyyy-mm-dd format. But you can use date_format() function to display the date in your required format.
Reply


Similar MySQL Database bytes