473,883 Members | 1,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mm/dd/yyyy format question

Roy
Hi all,

I'm creating a project that should always use this date format when displays
the dates or create dates. The back end database is a SQL Server and I like
to know what is the logical way to configure server, sql server or program so
it always deals with date as mm/dd/yyyy format.
Thanks in advance.

Roy
Dec 20 '05 #1
13 3312
"Roy" <Ro*@discussion s.microsoft.com > schrieb
I'm creating a project that should always use this date format when
displays the dates or create dates. The back end database is a SQL
Server and I like to know what is the logical way to configure
server, sql server or program so it always deals with date as
mm/dd/yyyy format.
Thanks in advance.


It depends on how you display and enter dates. If you manually convert from
DateTime to String, use the format "MM\/dd\/yyyy". If you use databound
controls, I'm not sure because I never use them. I only know that there is
the System.Windows. Forms.Binding.F ormat event that can be used for
formatting.

If the user enters dates, and if you want to force this input format, you
can use Date.ParseExact .

Concerning sql server: If you use parameters with SqlCommands, you simply
set the value of the parameter. The SqlCommand does the correct formatting
for you.

See also:
http://msdn.microsoft.com/library/en...ttingtypes.asp
(especially "Date and Time Format Strings")

Though, I would prefer an application using my regional settings, i.e.
displaying and accepting the date in regional format.
Armin

Dec 20 '05 #2
Roy,

In addition to Armin,

Be aware that if you would use your application in the North America
continent where this format is used 1/12/2005 would mean in Canada 1th
December 2005

Have a pleasure time in future with correcting the problems if you boss
decide that they will have a client/location in Canada and tell nothing to
you.

Cor
Dec 21 '05 #3
LDD
I'd also suggest using the regional settings. It makes the app much more
robust.
I recently ran into this particular issue, and am in the process of changing
things to use the regional settings

LDD

"Armin Zingler" <az*******@free net.de> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
"Roy" <Ro*@discussion s.microsoft.com > schrieb
I'm creating a project that should always use this date format when
displays the dates or create dates. The back end database is a SQL
Server and I like to know what is the logical way to configure
server, sql server or program so it always deals with date as
mm/dd/yyyy format.
Thanks in advance.
It depends on how you display and enter dates. If you manually convert

from DateTime to String, use the format "MM\/dd\/yyyy". If you use databound
controls, I'm not sure because I never use them. I only know that there is
the System.Windows. Forms.Binding.F ormat event that can be used for
formatting.

If the user enters dates, and if you want to force this input format, you
can use Date.ParseExact .

Concerning sql server: If you use parameters with SqlCommands, you simply
set the value of the parameter. The SqlCommand does the correct formatting
for you.

See also:
http://msdn.microsoft.com/library/en...ttingtypes.asp (especially "Date and Time Format Strings")

Though, I would prefer an application using my regional settings, i.e.
displaying and accepting the date in regional format.
Armin

Dec 21 '05 #4
Roy
Thanks everyone for your help.

"Cor Ligthert [MVP]" wrote:
Roy,

In addition to Armin,

Be aware that if you would use your application in the North America
continent where this format is used 1/12/2005 would mean in Canada 1th
December 2005

Have a pleasure time in future with correcting the problems if you boss
decide that they will have a client/location in Canada and tell nothing to
you.

Cor

Dec 21 '05 #5
On Tue, 20 Dec 2005 13:47:02 -0800, Roy
<Ro*@discussion s.microsoft.com > wrote:
Hi all,

I'm creating a project that should always use this date format when displays
the dates or create dates. The back end database is a SQL Server and I like
to know what is the logical way to configure server, sql server or program so
it always deals with date as mm/dd/yyyy format.
Thanks in advance.

Roy


Use the ISO 8601 format when passing date information as a string to
SQL server, i.e. "YYYYMMDD".

No ambiguity. No language dependence. No regional nonsense.

For more information, see
http://support.microsoft.com/default...b;en-us;173907

Another interesting article about SQL Server date handling:
http://www.sqljunkies.com/Article/66...C7FD826E5.scuk

More info about ISO 8601:
http://www.cl.cam.ac.uk/~mgk25/iso-time.html

As another poster replied, you should not presume that the
system is configured to handle dates formatted in any
particular manner. Specific (localized) formats should be reserved for
input validation and output representation.

Hope any of this helps.

Regards,

Joergen Bech

Dec 21 '05 #6
Joergen,

This is a VB.Net newsgroup not an SQL language newsgroup.

Why would you do that for an SQLSever which notate its dateTime in ticks and
for what has .Net very automatic localized methods?

To explain you more.
ISO8601 is used in Asia (not all countries)
dd-mm-yyyy is used in Europe/Africa/Australia/America with the exception of
USA and Mexico
mm-dd-yyyy is used in the USA and Mexico (from the last I am not even sure)

However with Net there is no need to think about that when you use the
settings of the OS (that is by doing nothing extra)

(If you use direct SQLServer without Net than you have to make a choose,
however that is not the situation).

In cases beside Net my preference is ISO8601 by the way.

Cor

"Joergen Bech @ post1.tele.dk>" <jbech<NOSPAMNO SPAM> schreef in bericht
news:fn******** *************** *********@4ax.c om...
On Tue, 20 Dec 2005 13:47:02 -0800, Roy
<Ro*@discussion s.microsoft.com > wrote:
Hi all,

I'm creating a project that should always use this date format when
displays
the dates or create dates. The back end database is a SQL Server and I
like
to know what is the logical way to configure server, sql server or program
so
it always deals with date as mm/dd/yyyy format.
Thanks in advance.

Roy


Use the ISO 8601 format when passing date information as a string to
SQL server, i.e. "YYYYMMDD".
For more information, see
http://support.microsoft.com/default...b;en-us;173907

Another interesting article about SQL Server date handling:
http://www.sqljunkies.com/Article/66...C7FD826E5.scuk

More info about ISO 8601:
http://www.cl.cam.ac.uk/~mgk25/iso-time.html

As another poster replied, you should not presume that the
system is configured to handle dates formatted in any
particular manner. Specific (localized) formats should be reserved for
input validation and output representation.

Hope any of this helps.

Regards,

Joergen Bech

Dec 21 '05 #7

The original question stated
"what is the logical way to configure server, sql server or program so
it always deals with date as mm/dd/yyyy format".

And I also said that I recommended the ISO approach when
"passing date information as a string" (I use it myself and have
never looked back).

I know that .Net takes care of all this provided that one goes
through the proper objects.

I guess my head was still in my last project where I bypassed
those objects in favor of building my sql inserts from scratch
for performance reasons.

Whatever the programming language or supporting constructs,
I still feel the links I provided are relevant to the question.

ISO 8601 specific to Asian countries? This is the first time I
have heard that. Can you provide me with some links to some
more information? As the article in the Microsoft link stated,
the ISO format is unambiguous to SQL Server and is recommended
for that reason, regardless of the locale settings or country.

I only mentioned the ISO format because other posters started
talking about mm-dd-yyyy and dd-mm-yyyy.

If the original question had been about what .Net classes/objects to
use in order to pass date information correctly to and from SQL
Server, I suppose we would have had an entirely different
discussion.

My apologies if I have misunderstood something.

Regards,

Joergen Bech

On Wed, 21 Dec 2005 17:05:58 +0100, "Cor Ligthert [MVP]"
<no************ @planet.nl> wrote:
Joergen,

This is a VB.Net newsgroup not an SQL language newsgroup.

Why would you do that for an SQLSever which notate its dateTime in ticks and
for what has .Net very automatic localized methods?

To explain you more.
ISO8601 is used in Asia (not all countries)
dd-mm-yyyy is used in Europe/Africa/Australia/America with the exception of
USA and Mexico
mm-dd-yyyy is used in the USA and Mexico (from the last I am not even sure)

However with Net there is no need to think about that when you use the
settings of the OS (that is by doing nothing extra)

(If you use direct SQLServer without Net than you have to make a choose,
however that is not the situation).

In cases beside Net my preference is ISO8601 by the way.

Cor

"Joergen Bech @ post1.tele.dk>" <jbech<NOSPAMNO SPAM> schreef in bericht
news:fn******* *************** **********@4ax. com...
On Tue, 20 Dec 2005 13:47:02 -0800, Roy
<Ro*@discussion s.microsoft.com > wrote:
Hi all,

I'm creating a project that should always use this date format when
displays
the dates or create dates. The back end database is a SQL Server and I
like
to know what is the logical way to configure server, sql server or program
so
it always deals with date as mm/dd/yyyy format.
Thanks in advance.

Roy


Use the ISO 8601 format when passing date information as a string to
SQL server, i.e. "YYYYMMDD".
For more information, see
http://support.microsoft.com/default...b;en-us;173907

Another interesting article about SQL Server date handling:
http://www.sqljunkies.com/Article/66...C7FD826E5.scuk

More info about ISO 8601:
http://www.cl.cam.ac.uk/~mgk25/iso-time.html

As another poster replied, you should not presume that the
system is configured to handle dates formatted in any
particular manner. Specific (localized) formats should be reserved for
input validation and output representation.

Hope any of this helps.

Regards,

Joergen Bech


Dec 21 '05 #8
Joergen,

The original question stated
"what is the logical way to configure server, sql server or program so
it always deals with date as mm/dd/yyyy format".
The SQL server nor a Net program do deal with a string format. Thet deal
with different ticks.
SQL server has ticks from 1000/3 millisecond starting at 1-1-1753 (for the
DateTime)
Net deals with ticks from a unit of hundred nanosecond starting at 1-1-1
And I also said that I recommended the ISO approach when
"passing date information as a string" (I use it myself and have
never looked back).

I did as well however Net has better methods. By using direct the internal
DateTime and only use the string when it is needed to show it on screen or
get it from the sceen.
I know that .Net takes care of all this provided that one goes
through the proper objects.

ISO 8601 specific to Asian countries? This is the first time I
have heard that. Can you provide me with some links to some
more information?
That is not so strange as you think that they don't use European languages.
The former communist countries have used it a while, however that is as well
gone again. I think that the Britans will drive earlier on the right lane
than ISO8601 is used in Europe. China started the Georgian calendar late in
1949 and Turkey in 1928. Most Islamic countries (not all see Turkey) have of
course there own calendar (Isreal as well an hebrewic). Therefore the main
ISO8601 countries are India and China. From other Asian countries I am not
sure what they use.

Searching for Calendar and ISO8601 in Google gives you a bunch of
information. So wants the state of Nevada only use ISO8601 in official
websites.
As the article in the Microsoft link stated,
the ISO format is unambiguous to SQL Server and is recommended
for that reason, regardless of the locale settings or country.
The article is clear for me from a probably SQL part of Microsoft, not from
the Net or the OS part. How would you look to it if it was writen by
Navision/Microsoft.
I only mentioned the ISO format because other posters started
talking about mm-dd-yyyy and dd-mm-yyyy.
That I understood, however those dates have given often misunderstandin gs,
while it is so fine done in Net.
If the original question had been about what .Net classes/objects to
use in order to pass date information correctly to and from SQL
Server, I suppose we would have had an entirely different
discussion.

The way as Armin wrote it was in my opinon clear for the question. That was
why I did not add anything beside the warning to it, while I mostly do that
in DateTime questions.

(In my opinion is it a pity that the VBNet IDE shows all dateTimes in USA
format, whatever it internal is. C# shows it in the culture format from the
system, my favorite would be as it was showed in ISO8601 in all IDE's,
however that is noted as point for the future)

I hope that you now understand why I gave a reply on your message.

Cor
Dec 21 '05 #9
adh
Good people, Look!
A simple daily question and 9 posts AND NO ANSWER!!!
All the heck with VS.NET and we are back at stone age to deal with the
master's creation date !!!
Microsoft PLEASEEEEEEEEEE EEE............ .........

Thanks, adh

*** Sent via Developersdex http://www.developersdex.com ***
Dec 26 '05 #10

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

Similar topics

3
3395
by: Alistair | last post by:
it's the idiot with his query strings again...."yippeee" I hear aaron shout this time the problem is with a date format query I have a query string thus strSQL = "SELECT * FROM users where creation_date >= #" & strthisweekstart & "# AND creation_date <= #" & strthisweekend & "#" strthisweek start is dateadd("d",-7,date) and strthisweekend is date(). The
3
8897
by: Ted Johnson | last post by:
The following query works fine against SQL Server 2000 here in the US: SELECT * from TNEWSARTICLES where CreatedOn < '2003-04-25 14:22' But in the UK, it returns this error: 80040e07: The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value If I change the format to YYYY-DD-MM, then it does work in the UK. But
4
16615
by: Claudia Fong | last post by:
Hi Is there a way to change a date format dd/mm/yyyy to m/d/yy? I have a textBox where the user should put a date, but no matter what format the user input dd/mm/yyyy or m/d/yy, I need to convert it to this format: m/d/yy. Cheers!
5
8400
by: Ben Williams | last post by:
Hello, I'm hoping i'm posting to the correct newsgroup - this question involves both a SQL database and VB. I am a newbie and i'm writing a program in which one of a handful of fields will have a date entered. The contents of this field (and others) need to be written back to a SQL database. The 'date' field will be input in the format of the Regional settings (mainly dd/mm/yyy for the UK). When it comes to the point where it is...
10
27038
by: rob | last post by:
I have a class that among others exposes a string property "Date". The date in this property is stored in the form yyyymmdd. Now I do the following 1) Generate a DataGridViewTextBoxColumn column for that property 2) Add the column to the datagridview 3) Populate a BindingSource by adding all instances of the above mentioned class. 4) Assign the BindingSource to the datagridview's DataSource property
12
29492
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as follows: function doDateCheckNow(source, args) { var oDate = document.getElementById(source.controltovalidate); // dd/mm/yyyy
17
5296
by: Petyr David | last post by:
Just looking for the simplest. right now my perl script returns an error messge to the user if the date string is invalid. would like to do this before accessing the server. TX
3
2903
by: Eric Layman | last post by:
Hi, In general, how do u configure/script to allow .net to accept date in dd/mm/yyyy format? By default, my sys only allows mm/dd/yyyy format. Eg: Take alook at
4
30275
by: Ashraf Ansari | last post by:
Hi, How Can I convert MM/dd/yyyy format into dd/MM/yyyy and the date which is converted into dd/MM/yyyy should be in DateTime format. I do not want to store it as a string. Please help Thanks in advance
0
9943
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
11151
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10750
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10419
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7134
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5804
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5996
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4225
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3237
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.