Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9111729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:34:30+00:00 2026-06-17T03:34:30+00:00

I have a WPF client that retrieves data using a DateTime from a WCF

  • 0

I have a WPF client that retrieves data using a DateTime from a WCF service.

When I put my computer on Rome time (+1) I see some strange behaviour with my results.

My WCF Method

        public IEnumerable<BookingType> BookingsForFollowingDayReport(DateTime date) {

        el = new ErrorLogging();
        el.CreateLog(db, new Entities.ErrorType() { DateLogged = DateTime.Now, Type = "DTE", Message = "Report Date: " + date.ToString() });

        var a = (from b in db.GetTable<BookingType>()
                 where b.TourStartDateTime >= date.Date && b.TourStartDateTime <= date.AddDays(1).Date
                 orderby b.TourStartDateTime
                 select b);

        if (a.Count() > 0) {
            el.CreateLog(db, new Entities.ErrorType() { DateLogged = DateTime.Now, Type = "DTE", Message = "Report Date: " + a.FirstOrDefault().TourStartDateTime });
        }

        return a;
    }

The service is online on some web server somewhere and now I call it from my WPF client. Note the logging I have inside my method.

My Calling Code

    public static async Task<Bookings> GetBookingsReport(DateTime forWhen) {
        Bookings bookings = new Bookings();
        if (MyNetwork.IsOnline) {
            var bookingTypes = new ReportsServiceClient.BookingType[0];

                //forWhen = new DateTime(2013, 01, 10);
                bookingTypes = await ReportsServiceClient.BookingsForFollowingDayReportAsync(forWhen);


            bookings.TourBookings = (from b in bookingTypes
                                     where b.RecordType == "H"
                                     select new Booking(b)).ToList();

        }
        return bookings;
    }

Now for the strangities…

I call the ‘calling code’ from a XAML code behind using a DatePicker‘s value like so: await DataManager.GetBookingsReport(datePicked.SelectedDate.Value); and I’ll
debug through the code to the point where BookingsForFollowingDayReportAsync is called.

The variable forWhen is actually the 10/01/2013, great! ..accept my logging code in WCF service says 09/01/2013 is sent through. So then I uncomment the line where I set forWhen manually – just to test – and it works, the logger says 10/01/2013.

I’ve tested this over a few days now and it always has a problem with tomorrows date, if I pick three days away (past or future) in my DatePicker for example the correct date is logged.

If I set my timezone back to UK GMT time, this bug does not happen at all as well.

I’ve got an idea it might be something to do with the date picker since setting forWhen manually removes the problem, but how can this be happening?

Edit 1
I’ve managed to solve the problem for now, by setting forWhen manually, using forWhens Values like so (as nonsensical as it looks):

forWhen = new DateTime(forWhen.Year, forWhen.Month, forWhen.Day);

I’m perplexed by the problem and the solution I’ve found to it… Any explanations?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T03:34:32+00:00Added an answer on June 17, 2026 at 3:34 am

    By default, WCF serializes and deserializes DateTime objects based on the local time zone. This means the DateTime from the client gets decremented on the server by one hour when it is deserialized in your case. Apparently your time portion is 0 (midnight), so that would explain yesterday’s date.

    One of the solutions is to explicitly set DateTime.Kind to DateTimeKind.Unspecified before you pass the DateTime variable to the service like so:

    DateTime forWhenSvcArg = DateTime.SpecifyKind(forWhen, DateTimeKind.Unspecified);
    

    That’s what you get when you set forWhen by means of calling the constructor also.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF client that is using WCF to call into a service
In my WPF client, I have a loop that calls a WCF service to
I have a WCF data service and a wpf client consuming it. I have
I am developing an application using WPF/MVVM. I have a WCF data service project
I have a WPF client application that connects to IIS that hosts WCF Data
I have WPF client consuming WCF service hosted in IIS. For authentication I am
I have a WPF client that is attached to WCF endpoint on a very
I have a WPF application from a client that I need to add a
I have a problem. I have coded a wcf client (WPF and c#) that
I have developed a WPF client which poupaltes some sample data into it from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.