Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Splitting Columns

Status
Not open for further replies.

SirGally

Technical User
Nov 30, 2006
13
0
0
GB
I have a Date/time column in the format 'DD\MM\YYY HH:MM:SS'

I need to query the time and not the date, but there on the same column.

so for example:

Print_Date

30/11/06 15:00:59
29/11/06 12:15:13
23/11/06 06:55:44

I need a query that will give all items printed before 18:00:00 EVERYDAY!

Ive tried CREATE VIEW coupled with Right(Print_Date,12)but kept getting errors!!

Any ideas??


 
Hi
Try substring([Print_Date], 10, 10)

This will give you a time value as a string

It might be better splitting the value into sections so format it

HHMMSS and casting this as a numeric value then you can say

if time < 180000 then true

Thanks
 
Code:
Select * 
From   Table
Where  [!]DatePart(Hour, [/!]Print_Date[!]) <= 18[/!]

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Thanks for the imput guys,

Used your method George, worked first time.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top