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

Problem with my format() functions...

Due to the much of VBScript inhibition in my early years of website
development, I exhaustively used the following code in my .NET
console applications.

oLog.setStartTime = Format(Now, "MM/dd/yyyy HH:mm:ss")

This worked fine, when ppl used the code in US.

When the same code was migrated to Singapore, the developers started
to complain about the apparent error that occurs, due to the local
machine settings.

For example a date like 04/25/2007 - the Format() Function which
depends on local machine settings is creating problems.

What is the best practise to get rid of the evil? Pls advise.

Apr 25 '07 #1
3 1108
Local setting shouldn't really matter because you are giving your own
formatting. Anyway, try this: DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss")

"n.net" wrote:
Due to the much of VBScript inhibition in my early years of website
development, I exhaustively used the following code in my .NET
console applications.

oLog.setStartTime = Format(Now, "MM/dd/yyyy HH:mm:ss")

This worked fine, when ppl used the code in US.

When the same code was migrated to Singapore, the developers started
to complain about the apparent error that occurs, due to the local
machine settings.

For example a date like 04/25/2007 - the Format() Function which
depends on local machine settings is creating problems.

What is the best practise to get rid of the evil? Pls advise.

Apr 25 '07 #2
Yeah just check

Dim sTime as DateTime
StartTime = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss")

When i try on 08/06/2007 it works. But when I change the date to
22/06/2007. (The dates I mentioned is 08-Jun-2007 and 22-Jun-2007)

The exception I get is "Cast from string "06/22/2007 10:27:49" to
type 'Date' is not valid."
Pls advise.

On Apr 25, 1:52 pm, Siva M <shiva...@online.excite.comwrote:
Local setting shouldn't really matter because you are giving your own
formatting. Anyway, try this: DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss")

"n.net" wrote:
Due to the much of VBScript inhibition in my early years of website
development, I exhaustively used the following code in my .NET
console applications.
oLog.setStartTime = Format(Now, "MM/dd/yyyy HH:mm:ss")
This worked fine, when ppl used the code in US.
When the same code was migrated to Singapore, the developers started
to complain about the apparent error that occurs, due to the local
machine settings.
For example a date like 04/25/2007 - the Format() Function which
depends on local machine settings is creating problems.
What is the best practise to get rid of the evil? Pls advise.- Hide quoted text -

- Show quoted text -

Jun 8 '07 #3
n.net wrote:
Yeah just check

Dim sTime as DateTime
StartTime = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss")

When i try on 08/06/2007 it works. But when I change the date to
22/06/2007. (The dates I mentioned is 08-Jun-2007 and 22-Jun-2007)

The exception I get is "Cast from string "06/22/2007 10:27:49" to
type 'Date' is not valid."
The code that you showed can not produce that error message, as you are
not converting a string to a date in that code.

When you parse the string, either specify a culture that uses that date
format, or use DateTime.ParseExact with the same formatting string as
you used to create the string.

--
Göran Andersson
_____
http://www.guffa.com
Jun 9 '07 #4

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

Similar topics

6
by: J | last post by:
Would anyone know if there a type tag to format a double? I have f for floating point, but cannot find one for double.
1
by: martini | last post by:
Problem with time zone on linux. I have a dual processor machine running with mandrake 10.1. I have some issues with the localtime and strftime functions. Sometimes it returns the date of the...
11
by: milkyway | last post by:
Hello, I have an HTML page that I am trying to import 2 .js file (I created) into. These files are: row_functions.js and data_check_functions.js. Whenever I bring the contents of the files into...
11
by: Grumble | last post by:
Hello, I have the following structure: struct foo { char *format; /* format string to be used with printf() */ int nparm; /* number of %d specifiers in the format string */ /* 0 <= nparm <=...
7
by: Kay | last post by:
1) If i want to read data from a txt file, eg John; 23; a Mary; 16; i How can I read the above data stopping reading b4 each semi-colon and save it in three different variables ? 2) If I...
4
by: Matt | last post by:
I'm trying to write a shared function that will convert all my phone numbers from format 1234567890 to (123) 456-7890. Here is my function that I wrote: Public Shared Function...
12
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...
27
by: comp.lang.tcl | last post by:
My TCL proc, XML_GET_ALL_ELEMENT_ATTRS, is supposed to convert an XML file into a TCL list as follows: attr1 {val1} attr2 {val2} ... attrN {valN} This is the TCL code that does this: set...
11
by: aljaber | last post by:
hi, i am facing a problem with my program output here is the program /*********************************************\ * CD Database * * ...
30
by: Einstein30000 | last post by:
Hi, in one of my php-scripts is the following query (with an already open db-connection): $q = "INSERT INTO main (name, img, descr, from, size, format, cat, host, link, date) VALUES ('$name',...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: 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: 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: 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...
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...

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.