sh3rIIf Posted April 22, 2004 Posted April 22, 2004 When formatting date from a database it's returned as: "2004/01/01 14:30", which is correct. But when run from a different machine the time is messed up. Displayed as "02:30". Checked regional settings on both machines and they match and formatting the time in .NET doesn't work. Can anyone help? :mad: :mad: Quote
wessamzeidan Posted April 22, 2004 Posted April 22, 2004 May be their timezones are different Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
sh3rIIf Posted April 22, 2004 Author Posted April 22, 2004 time zones and all other regional settings are the same on both machines. Quote
Denaes Posted April 22, 2004 Posted April 22, 2004 That's the same time, but in 24 hour time. On my project, I had to use strings rather than Date or Time. VERY frustrating. In Access, you can make Date/Time and set it to ONLY be date. Same with Time. Fine, thats what I needed. When I bring it over to VB.Net through a DataAdaptor, it comes through as 04/22/2004 00:00am, even though its ONLY the Date. Because of issues like these I had to use strings to hold the date and times in a database. Very frustrating, but I need to have returned what I put in, not extra garbage. Someday I'd like to find a workaround :) Quote
*Experts* Nerseus Posted April 22, 2004 *Experts* Posted April 22, 2004 A general rule of thumb is store date/time (even if it's just a Date) in a DateTime variable in your program. Only when you want to display it do you format it. You can use the overrides on ToString() to "hardcode" a format if you like. For example, to not show the time portion: string s = DateTime.Now.ToString("MM/dd/yyyy"); If you want a specific time format, or want to ensure that it's the same on every machine, it's probably best to use a "hardcoded" string format or use your own CultureInfo object to do the formatting. -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.