date problem

D

dave

Hi
I have one date/time type of field..
I' m trying to store only date in mm/dd/yyyy format using
INSERT Statement and

CONVERT(DATETIME,getdate(),101)

But still it stores both date & time in the database
field..How can I store only date in mm/dd/yyyy ???

Any help would be appreciated...
Thanx
dave
 
D

dave

thanx for help but now i have little bit diff probl

i wanna store only time in hh:mm:ss AM or PM without
storing dates...

i tried #hh:mm:ss# but it doesnt work...

thanx
dave
 
M

Maarten

somthing like
myTime = HOUR(Time()) & ":" & MIN(Time()) & ":" & SEC(Time())


or myTime = FormatDateTime(now(),vblongtime)
 
B

Bob Barrows [MVP]

dave said:
Hi
I have one date/time type of field..
I' m trying to store only date in mm/dd/yyyy format using
INSERT Statement and

CONVERT(DATETIME,getdate(),101)

But still it stores both date & time in the database
field..How can I store only date in mm/dd/yyyy ???
You will need to store it in a char or varchar column. Of course, this will
mean that you will need to convert it back to a datetime if you need to
treat it as a date (for example, if you have to sort it by date or do date
arithmetic).

Why do you think you need to store date without time in a particular format?
There's a good article in SQL Books Online (BOL - look for it in your SQL
Server program group in the windows Start menu) called "Using Date and Time
data". Please look it up and read it.The best weay to find it is to type
"datetime" into the index.

Bob Barrows
 
B

Bob Barrows [MVP]

Same solution: if you need to store formatted data, you need to store it in
a char or varchar column. Again, this complicates using the data if you need
to do any sorting or date arithmetic. Again - you should not need to worry
about how this data is stored. Apply the formatting when you extract the
data from the database.

Bob Barrows
 

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,146
Messages
2,570,832
Members
47,374
Latest member
anuragag27

Latest Threads

Top