473,396 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

WS Dates off by 1, HELP

JP
I have a WS that returns a dataset. When I serialize the data and display in
on the screen my dates always seem to be -1 or +1 of the date I exspected.
1/11/2005 10:00:00 PM
where should have returned 1/12/2005

However if I execute the WS directly the dates are correct.

<IssueDate>2005-01-12T00:00:00.0000000-06:00</IssueDate>

The field in SQL is a datetime field but only dates are stored (no time)

Any seggestions or ideas as to why this is occuring

Thanks

--
JP
..NET Software Develper
Nov 23 '05 #1
4 1147
Hello JP,
May be there is some time zone in the date thats getting changed according
to the machines timezone?
HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
I have a WS that returns a dataset. When I serialize the data and
display in on the screen my dates always seem to be -1 or +1 of the
date I exspected.

1/11/2005 10:00:00 PM where should have returned 1/12/2005

However if I execute the WS directly the dates are correct.

<IssueDate>2005-01-12T00:00:00.0000000-06:00</IssueDate>

The field in SQL is a datetime field but only dates are stored (no
time)

Any seggestions or ideas as to why this is occuring

Thanks

Nov 23 '05 #2
JP
How do i remove the TZ from the date which I assume is the -06:00
<IssueDate>2005-01-12T00:00:00.0000000-06:00</IssueDate>
Liek I said un the phical SQL table, all thats there is the date and I guess
SQL assumes midnight even though its not displayed in the table itself.
"Dilip Krishnan" wrote:
Hello JP,
May be there is some time zone in the date thats getting changed according
to the machines timezone?
HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
I have a WS that returns a dataset. When I serialize the data and
display in on the screen my dates always seem to be -1 or +1 of the
date I exspected.

1/11/2005 10:00:00 PM where should have returned 1/12/2005

However if I execute the WS directly the dates are correct.

<IssueDate>2005-01-12T00:00:00.0000000-06:00</IssueDate>

The field in SQL is a datetime field but only dates are stored (no
time)

Any seggestions or ideas as to why this is occuring

Thanks


Nov 23 '05 #3
CG
When you are creating dataset change all dates to GMT and then calculate
based on the machine recd. the data. This way you will never have timezone
issue.

"JP" wrote:
How do i remove the TZ from the date which I assume is the -06:00
<IssueDate>2005-01-12T00:00:00.0000000-06:00</IssueDate>
Liek I said un the phical SQL table, all thats there is the date and I guess
SQL assumes midnight even though its not displayed in the table itself.
"Dilip Krishnan" wrote:
Hello JP,
May be there is some time zone in the date thats getting changed according
to the machines timezone?
HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
I have a WS that returns a dataset. When I serialize the data and
display in on the screen my dates always seem to be -1 or +1 of the
date I exspected.

1/11/2005 10:00:00 PM where should have returned 1/12/2005

However if I execute the WS directly the dates are correct.

<IssueDate>2005-01-12T00:00:00.0000000-06:00</IssueDate>

The field in SQL is a datetime field but only dates are stored (no
time)

Any seggestions or ideas as to why this is occuring

Thanks


Nov 23 '05 #4
Store, expect, and return all your dates in Zulu (UTC) time with no time
zone. Your common tz is then 0. All calculations also done with UTC times.
Users of the data can then convert to local time if needed, etc.

public static string StoreDateTimeUtc(DateTime value)
{
// Date *must be UTC date already.
// e.g 2003-10-26T14:33:41.1234567Z
return value.ToString("yyyy-MM-ddTHH:mm:ssZ",
CultureInfo.InvariantCulture);
}

/// <summary>
/// Parses the UTC formatted string, returning DateTime in UTC.
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static DateTime ReadDateTimeUtc(string value)
{
return DateTime.Parse(value, CultureInfo.InvariantCulture,
DateTimeStyles.AdjustToUniversal);
}

--
William Stacey, MVP
http://mvp.support.microsoft.com

"JP" <JP@discussions.microsoft.com> wrote in message
news:2A**********************************@microsof t.com...
How do i remove the TZ from the date which I assume is the -06:00
<IssueDate>2005-01-12T00:00:00.0000000-06:00</IssueDate>
Liek I said un the phical SQL table, all thats there is the date and I guess SQL assumes midnight even though its not displayed in the table itself.
"Dilip Krishnan" wrote:
Hello JP,
May be there is some time zone in the date thats getting changed according to the machines timezone?
HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com
I have a WS that returns a dataset. When I serialize the data and
display in on the screen my dates always seem to be -1 or +1 of the
date I exspected.

1/11/2005 10:00:00 PM where should have returned 1/12/2005

However if I execute the WS directly the dates are correct.

<IssueDate>2005-01-12T00:00:00.0000000-06:00</IssueDate>

The field in SQL is a datetime field but only dates are stored (no
time)

Any seggestions or ideas as to why this is occuring

Thanks



Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: duikboot | last post by:
Hi all, I'm trying to export a view tables from a Oracle database to a Mysql database. I create insert statements (they look alright), but it all goes wrong when I try to execute them in Mysql,...
10
by: Colin Steadman | last post by:
I'm a stupid ASP programmer and I dont do Javascript (except for very simple tasks anyway), and I'm in a bit of a predicament. I've used a javascript table sorting script from here: ...
3
by: SJH | last post by:
I currently have reports (mostly graphs) that utilize dates entered into a form. The dates are pretty baisc from the standpoint of the start and end of the current fiscal year, the start and end...
18
by: PC Datasheet | last post by:
An Access user saw my name in a newsgroup and sent me a request for help on a project. As part of the project, a list of the dates in a month was needed. For anyone needing a list of dates in a...
12
by: Dixie | last post by:
I am trying to calculate the number of workdays between two dates with regards to holidays as well. I have used Arvin Meyer's code on the Access Web, but as I am in Australia and my date format is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.