Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

MySql date issue

Guest
Sep 20, 2008 Sep 20, 2008
hi i am inserting intp MySql date field, but when i insert the date 29/02/2009

i get the error MONTH

<cfset newdate = #DateFormat(CreateDate(form.vyear, form.vmonth, form.vday), "mm-dd-yyyy")#>

any ideas how to solve ths issue?
TOPICS
Advanced techniques
637
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 20, 2008 Sep 20, 2008
Craig

I believe in mysql dates must be cast yyyy-mm-dd, so just change dateformat in your code.

Buy Ben Forta's excellent book on mysql it makes it all seem easy.

Can someone now answer my cflayout question below craig's!!

Tim
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 20, 2008 Sep 20, 2008
The date isn't valid because 2009 isn't a leap year, 2008 is. There is no 29th February in 2009 🙂
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Sep 20, 2008 Sep 20, 2008
LATEST
craiglaw98 wrote:
> hi i am inserting intp MySql date field, but when i insert the date 29/02/2009
> <cfset newdate = #DateFormat(CreateDate(form.vyear, form.vmonth, form.vday), "mm-dd-yyyy")#>

If you need to insert a date, do not use DateFormat. That function returns a string not a date time object. Also, you do not need the # signs.

<cfset newdate = CreateDate(form.vyear, form.vmonth, form.vday)>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources