473,382 Members | 1,692 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,382 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 2144
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.