October 9, 2003 at 7:20 am
How do get this function to show only the date and leave off the time? Or is there another function I should be using?
Thanks webdaddy13
October 9, 2003 at 7:27 am
hi,
a quick and dirty way is to convert to a char field :-
select convert(char(11),getdate())
HTH
Paul
October 9, 2003 at 9:49 am
I appreciate the conversion statement but I really need to know how to autoatically populate that field date_entered without supplying the date from client side or server side programming
October 9, 2003 at 10:38 am
i think you need to have a time with all datetime fields. the only thing i can think of is to set the time to the same for each row :-
create table pgr_date_test
(col1 datetime)
insert into pgr_date_test
select convert(char(11),getdate())
select * from pgr_date_test
returns :-
09/10/2003 00:00:00
you then just need to ignore the time
Paul
October 9, 2003 at 11:28 am
quote:
I appreciate the conversion statement but I really need to know how to autoatically populate that field date_entered without supplying the date from client side or server side programming
Use Paul's suggection to create a default for the column:
ALTER TABLE MyTable ADD CONSTRAINT df_Date_Entered DEFAULT CONVERT(char(8),GETDATE(),112) FOR Date_Entered
--Jonathan
--Jonathan
October 9, 2003 at 6:36 pm
thank you guys this forum has really helped me...I will try it out you guys a great
I hope some day soon I can help you guys
webdaddy13
October 10, 2003 at 2:42 am
If look up CONVERT in SQL Books Online then you will see there are a whole load of different formats you can convert the datetime value into. It is very useful!
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply