Sql Server Datetime

  • Thread starter Thread starter Irishmaninusa
  • Start date Start date
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
 
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"
 
You can minutes instead of month. Use capital M. And look in "Custom
DateTime Format Strings" topic in the help.

Eliyahu

"Irishmaninusa"
 
Back
Top