vb.net 中的日期错误
这让我和我的老板都沮丧得抓狂:
我正在运行一个存储过程来从我的数据库中获取一些信息。它返回的值之一是日期字段。当我在 SQL 中手动执行存储过程时,我会得到一个值,但当我将数据写入页面时,我会得到一个值 + 1。
因此,例如,如果 SQL 表示日期应该是 12/11/2011 ,我的页面显示为 13/11/2011。
这似乎不是日期格式问题 - 我的日期以英国/欧洲格式从 SQL 中输出,.NET 页面以英国/欧洲格式显示 - 据我所知,我不是实际上,当我显示日期时加 1。
有没有人对我们犯的愚蠢错误有什么建议(在这一点上,我们都非常确定这是愚蠢的事情,因为我所有的谷歌搜索都没有发现其他人有这个问题)?
选择查询如下:
Select @TotalPrice as Price, Convert(varchar(10),@Departure, 103) as Departure,
@PImage1 as PImage1, @PImage2 as PImage2, @PImage3 as PImage3, PName, PBath,
PBed, PMaxSleep, PSwim, PLong, PLat, RIName, CIName, RName, CName, PTShortDesc,
PTLongDesc
from Property P,
PropertyText PT,
Region R,
RegionID RI,
Country C,
CountryID CI
where P.PID=@PID and P.RIID=RI.RIID and P.CIID=CI.CIID and
P.PID=PT.PID and PT.CID=PT.CID and C.CID=R.CID and LCode='EN' and
R.RIID=RI.RIID and C.CIID=CI.CIID
然后,我将 Departure 写入标签:
DepartureLabel.text = myReader1("Departure")
在任何阶段,我的页面中都没有任何 DateAdd 语句。
This one has both me and my boss tearing our hair out in frustration:
I'm running a stored procedure to get some information out of my database. One of the values it returns is a date field. When I manually exec the stored procedure in SQL, I get a value and yet when I write the data out onto the page, I get a value + 1.
So, for example, if SQL says the date should be 12/11/2011, my page is displaying it as 13/11/2011.
It doesn't appear to be a date format issue - my date's coming out of SQL in UK/Europe format and the .NET page is displaying it in UK/Europe format - and as far as I'm aware, I'm not actually adding 1 on when I display the date.
Does anyone have any suggestions for what stupid mistake (and at this point, we're both pretty sure it IS something silly since all my googling hasn't turned up anyone else with this problem) we've made?
The select query is as follows:
Select @TotalPrice as Price, Convert(varchar(10),@Departure, 103) as Departure,
@PImage1 as PImage1, @PImage2 as PImage2, @PImage3 as PImage3, PName, PBath,
PBed, PMaxSleep, PSwim, PLong, PLat, RIName, CIName, RName, CName, PTShortDesc,
PTLongDesc
from Property P,
PropertyText PT,
Region R,
RegionID RI,
Country C,
CountryID CI
where P.PID=@PID and P.RIID=RI.RIID and P.CIID=CI.CIID and
P.PID=PT.PID and PT.CID=PT.CID and C.CID=R.CID and LCode='EN' and
R.RIID=RI.RIID and C.CIID=CI.CIID
I'm then writing Departure to a label:
DepartureLabel.text = myReader1("Departure")
At no stage do I have any DateAdd statements in my page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要检查夏令时和区域设置。无论是在客户端还是在服务器上。
还要检查SQL Server中表中的实际值(不是通过使用客户端)来确定是服务器还是客户端。
You might need to check daylight savings time and regional settings. Both on the client and on the server.
Also check the actual value in the table in the SQL server (not by using the client) to find out whether it is the server or the client.