Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 time

Author  Topic 

wided
Posting Yak Master

218 Posts

Posted - 2011-02-24 : 11:11:57
hello

declare @date1 datetime
declare @date2 datetime
declare @date3 datetime

select @date1 = '01/01/1900 08:41'
select @date2 = '01/01/1900 08:00'
print @date1-@date2
the result is : 'janv 1 1900 12:41AM'
why not 'janv 1 1900 00:41AM'
i think a problem is am or pm
thanks

mandm
Posting Yak Master

120 Posts

Posted - 2011-02-24 : 11:20:21
Look at CONVERT in booksonline. The default format is what you've shown. If you want it to be different you'll need to use CONVERT to change it.
Go to Top of Page

wided
Posting Yak Master

218 Posts

Posted - 2011-02-24 : 11:25:17
how?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-02-24 : 11:27:56
You need to use in SELECT statement


declare @date1 datetime
declare @date2 datetime
declare @date3 datetime

select @date1 = '01/01/1900 08:41'
select @date2 = '01/01/1900 08:00'
select @date1-@date2

Print actually convert the date to varchar thus converting it to AM format

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-24 : 12:24:43
quote:
Originally posted by wided

hello

why not 'janv 1 1900 00:41AM'
i think a problem is am or pm
thanks




The answer of your why is in your value format ..

AM or PM is used when you are working over 12 hour format .. where as the one you are looking for is 24 hour format ... How could you want 24 hour format with AM or PM

Cheers
MIK
Go to Top of Page
   

- Advertisement -