Smart Client / Web Server Time Zone issue (WCF and SQL Server)

B

Burton Roberts

When I insert a date value through my winforms smart client to a WCF Web
service in a different time zone to SQL Server, the date recorded in SQL is
adjusted by the time zone. I'm in the Eastern Time Zone, my web server is
in the Central Time Zone. I create a datetime value by using a date picker
control which gives me an eastern datetime Dec 10, 2008 12:00 AM midnight.
I submit it to the WCF webservice and SQL Server gets it as Dec 9, 2008
11:00 PM. The field type is the new SQL Server 2008 Date type, so I'm not
even interested in the time part of the data. SQL Server truncates the time
for the date and Dec 9 gets stored instead of Dec 10.

Since all my workstations happen are in the Eastern Time zone I just
programatically add 61 minutes to the date before its submitted so that the
correct date is stored in SQL. That seems like a miserable hack, though,
and wonder if there's a more elegant solution.

Thanks
 
B

Burton Roberts

I suppose I could convert the date to a string and submit that instead and
convert back to date on the other side. That's one idea.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top