473,396 Members | 2,106 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,396 software developers and data experts.

Storing Dates

Hi,

What is the best way to store a date as text. I want to be able to read the
date from the external source (config file etc) and be able to interpret it
regardless of the local culture setting. The date may be stored using on
culture and read using another.

Thanks
Tim
Nov 21 '05 #1
3 1163
Using the sortable date/time pattern that conforms to ISO 8601 should give
you the best results.

It is the equivalent of yyyy-MM-ddTHH:mm:ss and can be used by specifying
the output as DateTime.ToString("s"). For this format the seprators are not
affected by the culture.

If the value needs to be timezone sensitive then even better results can be
achieved by converting the value to UTC prior to writing it and converting
the UTC value to local when reading it.

When reading the value use DateTime.ParseExact(<value>, "s", Nothing).
"Tim Marsden" <tm***@newsgroup.nospam> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,

What is the best way to store a date as text. I want to be able to read
the date from the external source (config file etc) and be able to
interpret it regardless of the local culture setting. The date may be
stored using on culture and read using another.

Thanks
Tim

Nov 21 '05 #2
Tim,

"Tim Marsden" <tm***@newsgroup.nospam> schrieb:
What is the best way to store a date as text. I want to be able to read
the date from the external source (config file etc) and be able to
interpret it regardless of the local culture setting. The date may be
stored using on culture and read using another.


In addition to the other replies, you can use
'System.Globalization.CultureInfo.InvariantCulture ' for formatting and
parsing the date:

\\\
Imports System.Globalization
..
..
..
Dim s As String = Now().ToString(CultureInfo.InvariantCulture)
Dim d As Date = Date.Parse(s, CultureInfo.InvariantCulture)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3
Many Thanks for your replies they seem to work fine.

Tim

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eR**************@TK2MSFTNGP15.phx.gbl...
Tim,

"Tim Marsden" <tm***@newsgroup.nospam> schrieb:
What is the best way to store a date as text. I want to be able to read
the date from the external source (config file etc) and be able to
interpret it regardless of the local culture setting. The date may be
stored using on culture and read using another.


In addition to the other replies, you can use
'System.Globalization.CultureInfo.InvariantCulture ' for formatting and
parsing the date:

\\\
Imports System.Globalization
.
.
.
Dim s As String = Now().ToString(CultureInfo.InvariantCulture)
Dim d As Date = Date.Parse(s, CultureInfo.InvariantCulture)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

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

Similar topics

8
by: Angelos | last post by:
What do you think is the best way to store Dates into a database ? If you want to keep logs or buckups.... I am using date('dmYHis') but I doesn't work really well ... Is it better to use...
2
by: Robert | last post by:
I have no problem storing dates + times in a System.DateTime object. In addition, it's easy to output a Time as a string from an existing Date/Time. But I'm having trouble storing a time only. ...
1
by: Thomas R. Hummel | last post by:
Hello all, I have been working with several databases here that are basically data marts. A lot of the entities have an attribute that is a particular year and month. For example, a financial...
8
by: Zvonko | last post by:
Hi! I would like to get the clients date and time (his system time) and store it somewhere so I can use it in my code later. (insert it to database!). Any ideas Zvonko
5
by: dd_bdlm | last post by:
Hi all I have a database that stores customer records and their associated insurance details. I need to be able to track any changes made to that record within a set time period ie if details...
10
by: IntraRELY | last post by:
Here is my code, but get errors: Dim installment = 1 Dim beginDate = "1/1/03" Dim endDate = "1/1/08" Dim dates(5) As Array While installment <= 5 endDate = DateAdd(DateInterval.Year, 1,...
7
by: fauxanadu | last post by:
Is it possible to store dates before 01/01/0100 A.D. (such as for as database storing world events would require) using MS Access? Verbose Explination I need to be able to store dates before...
2
by: billelev | last post by:
Hi there, Does anyone know how to store a constant in VBA that is set using a function or sub-routine? Here is the scenario. When I load up Access for the first time, I'd like to calculate...
1
by: nightscorpion | last post by:
Hello everyone. i have 2 dates given FromDate :1998-04-13T00:00:00 ToDate :1998-04-18T23:59:00 i would like to store these two days as single dates in the table in my db could...
4
by: John A Grandy | last post by:
What are some best practices for storing pure dates and pure times in .NET ? I notice that DateTime.TimeOfDay() returns type TimeSpan , which is certainly sufficient for storing pure times , but...
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...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.