473,441 Members | 1,928 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,441 software developers and data experts.

MSSQL help using date function - to get peak range of ATIME and EndTime

29
Hi anyone - appreciate any help

I would like to get * one column * with that min of the day instead of hr and min separately
So the first line for example 18:50 pm would be the 1130 min of the day
And if it was 6:50 am would be 410 min of a day
What is the best function I can use in my select statement to get this and be able to group by it ?

select datepart(yyyy,ATIME)as yr, datepart(mm,ATIME)as mth, datepart(dd,ATIME)as daday
,datepart(hh,ATIME)as hr,datepart(mi,ATIME)as strtmin
From table
Where (ATIME >= '2010-02-01 00:00:00') and (ATIME <= '2010-02-28 23:59:59')
and datename(weekday,ATIME) in ( 'Friday','Saturday','Sunday')
group by datepart(yyyy,ATIME),datepart(mm,ATIME),datepart(d d,ATIME),
datepart(hh,ATIME),datepart(mi,ATIME)
order by strtmin desc

yr mm dd hr mi
2010 2 13 18 50
2010 2 6 18 50
2010 2 26 14 50
2010 2 28 9 50
2010 2 14 20 49
2010 2 20 16 49
2010 2 12 1 49
2010 2 28 19 49
2010 2 5 1 49

My columns looks like this
ATIME EndTIME

2010-02-01 00:00:00.000 2010-02-01 00:02:30.000
2010-02-01 00:00:00.000 2010-02-01 00:00:26.000
2010-02-01 00:00:02.000 2010-02-01 00:55:53.000
2010-02-01 00:00:02.000 2010-02-01 00:16:35.000

Thanks in advance
Mar 19 '10 #1
2 1826
Delerna
1,134 Expert 1GB
Don't know it there is a function (probably) but it is an easy math problem

SELECT datepart(hh,ATIME) * 60 + datepart(mi,ATIME) as MinuteOfTheDay
FROM........
Mar 21 '10 #2
ck9663
2,878 Expert 2GB
Are you talking about getting the elapsed time in minutes since midnight? Use DATEDIFF().

Happy Coding!!!

~~ CK
Mar 22 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Iain Miller | last post by:
Trying to get my head round building a DB to analyse phone bills. On the surface its fairly simple - duration in seconds x cost per minute/60. The problem arises with working out what time of...
14
by: Kukurydz | last post by:
I've got such problem: My database is stored on MSSQL Server. I have to write reports for it in MSAccess. I've got a problem with creating a query which will select records from MSSQL table with...
6
by: Marc Pelletier | last post by:
Hello, Are nested function calls inefficient (or inherently evil)? In Delphi I've seen small but significant performance improvements by always declaring a local variable and 'unwrapping' the...
0
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control...
11
by: shsandeep | last post by:
I used the following query to retrieve the date in dd-mon-yyyy format. db2 => SELECT RTRIM(CHAR(DAY(COVG_TYP_STRT_DT))) || '-' || RTRIM(MONTHNAME(COVG_TYP_STRT_DT)) || '-' ||...
8
by: Grey | last post by:
I have following problem: table includes times for startup and end of operation as datetime field related to daily shift operations: dateid date starttime endtime 458 2006-12-29 22:00 ...
1
by: AllyFrog | last post by:
Hello, I have a database which manages bookings for casual staff. When bookings are for just one day, then they can be entered as a new record into a form. Frequently however, a booking may be...
6
by: poolboi | last post by:
hi all, i've got the following program that needs yr help: use Win32::OLE; # use existing instance if Excel is already running eval {$ex =...
1
by: saran3b2 | last post by:
Hi all, Please suggest us. My xml file is <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="Y:\02-Thomson\Users\APT\xsl\vinoth-new.xsl"?> <report>...
1
by: remya1000 | last post by:
I’m using VB.net 2003 application program. I am trying to do a select statement whereby I'm searching between 2 datetime values that are being stored as datetime. records are stored inside...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.