SQL-Server

Moderators: None (Apply to moderate this forum)
Number of threads: 435
Number of posts: 788

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Comparing Time elements of dates Posted by anrice on 15 Mar 2004 at 7:43 AM
This message was edited by anrice at 2004-3-15 7:49:1

I want to check the time element of a date entered against the
a field that stores the Working Day Start Time to see if the time element of the date entered precedes or is after the Day Start Time.

I can currently do this using datediff and playing around with date calculations but what is the easiest way to do so?

The code I am currently using is along the lines of:

:
declare @dat_starttime as datetime,
@dat_to as datetime,
@int_interval as dec (7,5)

SELECT @dat_starttime = '14:00', @dat_to = '15-mar-2004 13:15'

select @int_interval = datediff(minute,@dat_starttime, @dat_to - datediff(day,@dat_starttime,@dat_to))
print @int_interval
:

Regards
anrice


Report
Re: Comparing Time elements of dates Posted by GideonOmega on 15 Mar 2004 at 1:16 PM
: This message was edited by anrice at 2004-3-15 7:49:1

: I want to check the time element of a date entered against the
: a field that stores the Working Day Start Time to see if the time element of the date entered precedes or is after the Day Start Time.
:
: I can currently do this using datediff and playing around with date calculations but what is the easiest way to do so?
:
: The code I am currently using is along the lines of:
:
: :
: declare @dat_starttime as datetime,
: @dat_to as datetime,
: @int_interval as dec (7,5)
:
: SELECT @dat_starttime = '14:00', @dat_to = '15-mar-2004 13:15'
:
: select @int_interval = datediff(minute,@dat_starttime, @dat_to - datediff(day,@dat_starttime,@dat_to))
: print @int_interval
: :
:
: Regards
: anrice
:
:
:


if all your doing is checking to see if one date is greater then the other, then you should be able to do it directly, as in:
if date1 > date2 .....



C:\Dos
C:\Dos Run
Run Dos Run


Report
Re: Comparing Time elements of dates Posted by anrice on 16 Mar 2004 at 2:22 AM
I'm not comparing dates at all.

The system has a setting for StartTimeOfDay which indicates the working start time.

I need to take the time element of the actual transaction date and compare the time element to the StartTimeOfDay.

Regards
anrice



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.