473,545 Members | 721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.setStartTi me = 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 1115
Local setting shouldn't really matter because you are giving your own
formatting. Anyway, try this: DateTime.Now.To String("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.setStartTi me = 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.To String("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...@onlin e.excite.comwro te:
Local setting shouldn't really matter because you are giving your own
formatting. Anyway, try this: DateTime.Now.To String("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.setStartTi me = 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.To String("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.ParseE xact 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
30150
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
1351
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 system in a GMT format and sometimes in CEST format (that I have configured on the linux timezone configuration for Spain Time zone). Any ideas?, Is it...
11
1897
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 this HTML file, all is OK but whenever the functions are separated (as it is now), when I run the page, I get the following error: Line 73,...
11
5920
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 <= 4 */ };
7
2806
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 enter a number, can I use to call a particular node ? eg enter a number: 3 calling node of number 3 is it possible ?
4
1833
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 CheckPhone(byVal val as String) as String dim strCheckPhone as String If val = "" Then strCheckPhone = ""
12
29427
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
27
5098
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 contents ]; close $fileID
11
1918
by: aljaber | last post by:
hi, i am facing a problem with my program output here is the program /*********************************************\ * CD Database * * * \*********************************************/
30
2768
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', '$img', '$descr', '$user', '$size', '$format', '$cat', '$host', '$link', '$date')" or die(mysql_error()); And when the query gets executed i get...
0
7398
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7805
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...
1
7416
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7752
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...
0
5969
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5325
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4944
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...
0
3449
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...
1
1878
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.