473,385 Members | 1,925 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,385 software developers and data experts.

Date & DateTime datatypes format

Ed
Hi there,

My problem is the following: When I assign a custom formatted Date & Time to
a Date variable it loses it’s formatting. Ex. 2005-06-07 15:46
[Format(Now(), "yyyy-MM-dd HH:mm")] now when I assign this to a variable of
type Date or DateTime this becomes 2005/06/07 03:46:00

The same code work flawlessly on various other machines, thus I presume this
is settings related. I know that the Time function in VB.NET reads from the
system time, which you set in Regional Settings under the Control Panel. I
did try to change the settings but it did not seem to work, unless I'm not
setting it up correctly.

Any ideas would be appreciated.

Thanx
Jul 21 '05 #1
3 2145
Ed,

Showing samples whith dates that can mean 6 july or june 7 is in my opinion
not the best way to show a problem. Can you show it with a date as december
31.

Cor
Jul 21 '05 #2
My problem is the following: When I assign a custom formatted Date & Time to
a Date variable it loses it’s formatting.
Why do you assign it to a Date _after_ you perform the formatting? If
you have Option Strict turned on you shouldn't even be allowed to
assign a String to a Date like that.

Ex. 2005-06-07 15:46
[Format(Now(), "yyyy-MM-dd HH:mm")] now when I assign this to a variable of
type Date or DateTime this becomes 2005/06/07 03:46:00


A Date (or DateTime) variable doesn't carry any formatting
information. You can display it in whatever format you want with the
Format function or DateTime.ToString().

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #3
Ed <Ed@discussions.microsoft.com> wrote:
My problem is the following: When I assign a custom formatted Date & Time to
a Date variable it loses it?s formatting. Ex. 2005-06-07 15:46
[Format(Now(), "yyyy-MM-dd HH:mm")] now when I assign this to a variable of
type Date or DateTime this becomes 2005/06/07 03:46:00
Yes, in the same way that if you parsed a string saying "10.00000" as a
double, you wouldn't keep the formatting from that either. The format
isn't any part of the DateTime logically - an instant in time doesn't
have a format associated with it any more than a number does.
The same code work flawlessly on various other machines, thus I presume this
is settings related.


Well, it would "work flawlessly" if the format you used happened to be
the system default one...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #4

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

Similar topics

2
by: Andy Fish | last post by:
Hi, I have an application with a vb6 client that talks to a java server and passes XML back and forward, and I'm wondering what's the best format to transfer date/time values between them in an...
3
by: J. Muenchbourg | last post by:
while inserting new records into SQL, i'm using the folloinwg sqlstatement> Dim MySQL as string = "Insert into roster (pname, pnotes, thedate) values (@pname, @pnotes, @thedate)" the sql...
4
by: Robert Scarborough | last post by:
I have a Table in a Typed Dataset which contains a Date field called EventDate. I've ensured that the field is defined as Date as opposed to DateTime in the Typed Dataset. When I generate an...
2
by: [Yosi] | last post by:
DateTime dd = DateTime.ParseExact ("27/09/2003", "dd/MM/yyyy"); I still get an error : "(939): No overload for method 'ParseExact' takes '2' arguments" >-----Original Message----- >Dates...
3
by: Ed | last post by:
Hi there, My problem is the following: When I assign a custom formatted Date & Time to a Date variable it loses it’s formatting. Ex. 2005-06-07 15:46 now when I assign this to a variable of...
2
by: John A Grandy | last post by:
VS05 : GridView control config'd to use SPs in SS05 One of the SPs takes a vchar(50) which in the T-SQL needs to be converted to a DateTime. How should I have the GridView format the text the...
2
by: Bill Nguyen | last post by:
I receive data in an XML file with the following date/time format. While I can parse the date & time using string function, I would like to know if this is some sort of datetime in SQLserver that I...
4
by: Terry | last post by:
I have a TextBox with a date such as 15/01/2006 which I want to cast into a variable as a short date 15/01/06, also I need to cast a time such as 07:30 A.M. into a variable as a short time. What...
6
by: Mark | last post by:
Hi, i have an application which works with date. The regional settings of the computer (XP prof. dutch version) are set to French (Belgium). Asp.net and Sql server take the short date format of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.