如何将日期"dd-mm-yyyy"格式化为"yyyy-mm-dd"
问题描述:
在我的应用程序中,我以"dd-MM-yyyy"格式获取日期.当我将其发送到sql时,它正在考虑将第一个值"dd"作为月份.
例如:
我正在传递两个日期输入,例如date1是"1-1-2011",date2是"07-1-2011",当传递此sql时,它被视为1月到7月
建议我如何将日期值"dd-MM-yyyy"格式化为"yyyy-MM-dd"
In my application i am getting date in this format "dd-MM-yyyy" . When i send this to sql it is considering like the first value "dd" as month.
example:
I am passing two date inputs,Say for example date1 is ''1-1-2011'' and date2 is ''07-1-2011'',When pass this sql, Its is considering as jan to july
suggest me how to format the date value ''dd-MM-yyyy'' to ''yyyy-MM-dd''
答
在dd-中传递日期MMM-yyyy格式,之后不会有任何混淆.
如果解决您的问题,则标记为答案
pass your date in dd-MMM-yyyy format, there will not be any confusion after that.
mark as answer if solves your problem
感谢
但是这里的问题是我无法发送"MMM"格式,为什么,因为我有一个Java脚本日期选择器,它只会返回类似"dd-MM-yyyy"的格式
建议我如何进行这项工作,这是我无法更改日期向客户显示的日期格式
如果我得到像这样的格式"yyyy-MM-dd",那就太好了.这对于sql来说很容易理解
Thanks
But the problem here is I cant send the "MMM" format, Why because i have a java script date picker which will return only the format like this "dd-MM-yyyy"
suggest me how to make this work, Thing is i cant change the format of date how it is displaying to the client
it would be great if i get the format like this ''yyyy-MM-dd''. This can be easily understandable to sql
使用sql中的日期转换功能.
use datecasting function in sql .