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

DateTime string formatting for Oracle db?

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

Oct 31 '06 #1
7 17039
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
Oct 31 '06 #2
Hello sherifffruitfly,

Console.WriteLine(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
Oct 31 '06 #3

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

Oct 31 '06 #4
sherifffruitfly <sh*************@gmail.comwrote:
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.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 1 '06 #5

Jon wrote:
sherifffruitfly <sh*************@gmail.comwrote:
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

Nov 1 '06 #6
sherifffruitfly <sh*************@gmail.comwrote:
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.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 1 '06 #7

Jon wrote:
sherifffruitfly <sh*************@gmail.comwrote:
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

Nov 1 '06 #8

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

Similar topics

2
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
5
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'
5
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 ''.
0
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...
3
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
7
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: ...
27
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 ?
2
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
2
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 #...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.