可能是正确的保存日期为sql中的varchar?

可能是正确的保存日期为sql中的varchar?

问题描述:

I usually keep the date as timestamp in sql.

But now Im doing a project that I want that the date appears like "Wednesday, 30 April, 2014".

And Im using datepicker to format the date like I want and its working fine.

$('.datepicker').datepicker({
    dateFormat: 'DD, d MM, yy',         
});

But now I am in doubt, if it is appropriate to save date as varchar, but also dont seems possible to save "Wednesday, 30 April, 2014" as timestamp or datetime or someting else date option.

What do you think its better?

我通常将日期保留为sql中的时间戳。 p>

但是现在我 做一个我希望日期显示为“2014年4月30日星期三”的项目。 p>

我使用datepicker格式化日期,就像我想要的那样,并且工作正常。 p >

  $('。datepicker')。datepicker({
 dateFormat:'DD,d MM,yy',
}); 
  code>  pre>  
 
 

但现在我有疑问,如果将日期保存为varchar是合适的,但似乎也不可能将“2014年4月30日星期三”保存为时间戳或日期时间或其他日期选项。

您认为它更好吗? p> div>

Use DateTime or TimeStamp but do not use a VarChar.

What do you think its better?

This type of question are problematic on *, but it has been asked before.

If you ever store it as a VARCHAR it will make your life very hard. Because doing calculation on dates will just be a real hassle.