JQuery DatePicker,日期为几天或几个月的日期格式问题 [英] JQuery DatePicker, Date Format Problems for dates with single days or months

查看:73
本文介绍了JQuery DatePicker,日期为几天或几个月的日期格式问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,我会从两个日期选择器中选择两个日期,然后按提交.
提交时,一条sql语句会将这两个日期放入数据库中.
问题是如果日期是一位数字,即1/11/2011,则将11/1/2011放入数据库中.
但是,如果日期是两位数,即2011年11月16日,则该日期将被放入数据库中.

如果可以的话请帮忙.

代码如下:

sql ="INSTO INTO特殊项(用户名,公司,特殊项,DateFrom,DateTo,DateStamp,电话号码,网站)VALUES(""+ txtBoxHiddenCompany.Text +",""+ txtBoxCompany.Text +"'',' '"+ txtBoxSpecialOffer.Text
+'',""+ DateTime.Parse(String.Format(" {0:d/M/yy},txtBoxDateFrom.Text))+"''," + DateTime.Parse(String.Format ("{0:d/M/yy}",txtBoxDateTo.Text))+'',""+时间+"''," + txtBoxPhone.Text +"," + txtBoxWebSite .Text +'')";

我已经尝试过{0:d}和{0:dd/MM/yy}知道是否有效

干杯

I have a problem will by I pick two dates from two date pickers and then press submit.
On submission an sql statement puts these two dates into the database.
Problem is if the day is a single digit ie 1/11/2011 then 11/1/2011 is put into the database.
However if the day is a double digit ie 16/11/2011 then that is the value that is put into the database.

Please help if you can.

Code below:

sql = "INSERT INTO Specials (Username, Company, Special, DateFrom, DateTo, DateStamp, Phonenumber, Website) VALUES (''" + txtBoxHiddenCompany.Text + "'',''" + txtBoxCompany.Text + "'',''" + txtBoxSpecialOffer.Text
+ "'',''" + DateTime.Parse(String.Format("{0:d/M/yy}", txtBoxDateFrom.Text)) + "'',''" + DateTime.Parse(String.Format("{0:d/M/yy}", txtBoxDateTo.Text)) + "'',''" + time + "'',''" + txtBoxPhone.Text + "'',''" + txtBoxWebSite.Text + "'')";

I have tried {0:d} and {0:dd/MM/yy} to know avail

Cheers

推荐答案


解决了 String.Format("{0:d}",txtBoxDateFrom.Text)
String.Format("{0:d}",txtBoxDateTo.Text)

在sql语句中
Solved it with
String.Format("{0:d}", txtBoxDateFrom.Text)
String.Format("{0:d}", txtBoxDateTo.Text)

in the sql statement


这篇关于JQuery DatePicker,日期为几天或几个月的日期格式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆