Sql Server Datetime

I

Irishmaninusa

Hello Everyone,

I am trying to pull back value from my database and the value in the field
is 2004-10-16 16:48:36.840

but when I store that in a string variable it gets converted into real time
10/16/2004 4:48:36PM

I want to keep the value as is and not have it converted, so I tried to use
the format function


Format(oEncRow.Item(2), "yyyy-mm-dd h:mm:ss.fff")

and this is what is returned from the above function

2004-48-16 4:48:36.840


Anyone have any ideas on how I can keep this value as it is stored in the
database
 
M

Marina

First off, the way it is stored in the database is a date. When you see it
in query analyzer or whatever, it is just some predefined conversion to a
string.

You need to look up formatting strings for datetime. 'm' is for minutes
that don't have a leading zero - you are using it in the month placeholder.
You need to use 'M' instead (or 'MM' for month with leading zeros).

Also, you can use 'H' for a 24 hr format for hours without leading zeros (or
'HH' with leading zeros).

"Irishmaninusa"
 
E

Eliyahu Goldin

You can minutes instead of month. Use capital M. And look in "Custom
DateTime Format Strings" topic in the help.

Eliyahu

"Irishmaninusa"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top