Hi,
God I hate datetime string formatting...
How do I get a string of the form "04-Oct-2006", for example, from a
DateTime object?
Thanks a jillion,
cdj 7 17075
Hi,
date.ToString(" dd-MMM-yyyy");
--
rgds, Wilfried [MapPoint MVP] http://www.mestdagh.biz
sherifffruitfly wrote:
Hi,
God I hate datetime string formatting...
How do I get a string of the form "04-Oct-2006", for example, from a
DateTime object?
Thanks a jillion,
cdj
Hello sherifffruitfly ,
Console.WriteLi ne(DateTime.Now .ToString("dd-MMM-yy"));
sHi,
s>
sGod I hate datetime string formatting...
s>
sHow do I get a string of the form "04-Oct-2006", for example, from a
sDateTime object?
s>
sThanks a jillion,
s>
scdj
s>
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Wilfried Mestdagh wrote:
Hi,
date.ToString(" dd-MMM-yyyy");
dammit all to hell - I coulda SWORN I tried that and it didn't work.
lol!
Guess I didn't - thanks!
cdj
sherifffruitfly <sh************ *@gmail.comwrot e:
God I hate datetime string formatting...
How do I get a string of the form "04-Oct-2006", for example, from a
DateTime object?
From your subject line, it *sounds* like you're trying to write a SQL
statement with the literal value in it. It's a *much* better idea to
use a parameterised SQL statement so that you don't need to do
formatting, escaping etc.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jon wrote:
sherifffruitfly <sh************ *@gmail.comwrot e:
God I hate datetime string formatting...
How do I get a string of the form "04-Oct-2006", for example, from a
DateTime object?
From your subject line, it *sounds* like you're trying to write a SQL
statement with the literal value in it. It's a *much* better idea to
use a parameterised SQL statement so that you don't need to do
formatting, escaping etc.
That sounds lovely. If only I knew what it meant - lol!
I'm using the Oracle .net data provider ado.net stuff. It seems
perfectly happy translating DataSet-string-dates into bonafide
Oracle-date-dates, so where's the harm?
If you'll give me detail about the approach you're talking about, I'm
more than happy to give it a whirl....
Thanks for the idea,
cdj
sherifffruitfly <sh************ *@gmail.comwrot e:
From your subject line, it *sounds* like you're trying to write a SQL
statement with the literal value in it. It's a *much* better idea to
use a parameterised SQL statement so that you don't need to do
formatting, escaping etc.
That sounds lovely. If only I knew what it meant - lol!
I'm using the Oracle .net data provider ado.net stuff. It seems
perfectly happy translating DataSet-string-dates into bonafide
Oracle-date-dates, so where's the harm?
a) It means you need to get it right
b) It makes your code harder to port to other providers
c) If you do the same thing with other data types (and particularly
strings) you leave yourself open to SQL injection attacks if you're not
careful
If you'll give me detail about the approach you're talking about, I'm
more than happy to give it a whirl....
See http://www.pobox.com/~skeet/csharp/faq/#db.parameters
If that doesn't help, I'm sure the ADO.NET newsgroup will be happy to
provide more details :)
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jon wrote:
sherifffruitfly <sh************ *@gmail.comwrot e:
If you'll give me detail about the approach you're talking about, I'm
more than happy to give it a whirl....
See http://www.pobox.com/~skeet/csharp/faq/#db.parameters
If that doesn't help, I'm sure the ADO.NET newsgroup will be happy to
provide more details :)
Oooh - there's an ado.net group! See ya!
Thanks for the overview-idea-page!
lol :)
cdj This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Randall Smith |
last post by:
Is there an existing module or script that can convert a datetime string
of unknown format to a python datetime object ?
Randall
|
by: Thomas Philips |
last post by:
Consider the following simple dictionary
e={1:'one', 2: 'two'}
e
>>>'one'
However, If I attempt to print e using a formatted string
print " %(1)s" %e,
I get a KeyError: '1'
|
by: rodney.maxwell |
last post by:
Was doing some string formatting, noticed the following:
>>> x = None
>>> "%s" % x
'None'
Is there a reason it maps to 'None'? I had expected ''.
|
by: David Rifkind |
last post by:
I've seen some strange string formatting behavior on several XP and 2000
machines. I can get the same results with Graphics.DrawString, but the
easiest way to see it is to put a label on a VB or C# form, leave the
label's font setting at the default, set AutoSize to true, and set the
text property to a long string of narrow characters, like:
llllllllllllllllllllllllllllllllllllllll
The first couple dozen or so 'l's look okay, but the...
|
by: Franck |
last post by:
hello,
i'm looking for code (C# preferably)
in order to change programmatically in a datagrid
the string formatting expression of one bound colum
thank you
| |
by: Steven D'Aprano |
last post by:
I have a sinking feeling I'm missing something really,
really simple.
I'm looking for a format string similar to '%.3f'
except that trailing zeroes are not included.
To give some examples:
Float String
1.0 1
|
by: fdu.xiaojf |
last post by:
Hi,
String formatting can be used to converting an integer to its octal or
hexadecimal form:
'307'
'c7'
But, can string formatting be used to convert an integer to its binary
form ?
|
by: pchadha20 |
last post by:
Hi,
I have forget the host string of oracle.
Now i am facing difficulty to login to oracle.
try to help to get solution
Regards.
pchadha20
|
by: Tim Chase |
last post by:
Is there an easy way to make string-formatting smart enough to
gracefully handle iterators/generators? E.g.
transform = lambda s: s.upper()
pair = ('hello', 'world')
print "%s, %s" % pair # works
print "%s, %s" % map(transform, pair) # fails
with a """
TypeError: not enough arguments for format string
|
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...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |