Answered by:
i want a query - Which is larger than a date and a time, but time only on the first query is. (where date > '1391/11/02' and time > '10:21' )

-
text/html 7/6/2013 10:20:45 PM mohammad rabiyi 0
Question
Answers
-
text/sourcefragment 7/7/2013 8:11:47 PM Duane Dicks 1
Sorry - you probably want this:
SELECT * FROM #Mytest WHERE (theDate = '1391\11\02' AND theTime > '10:21') OR thedate > '1391\11\02'
- Proposed as answer by Duane Dicks Sunday, July 07, 2013 8:12 PM
- Marked as answer by Allen Li - MSFTMicrosoft contingent staff, Moderator Wednesday, July 24, 2013 2:33 AM
All replies
-
text/html 7/7/2013 6:31:15 PM Duane Dicks 0
You cant do this using the sql server date data type.
The lowest date value in sql server is 1753-01-01....
The only way you can achieve this is by coding some fancy method of representing these dates.
BTW, what data will you actually have dating back to 1391? - who would have actually recorded data from back then?
-
text/html 7/7/2013 7:00:19 PM mohammad rabiyi 0
hi
<You cant do this using the sql server date data type.>
<The lowest date value in sql server is 1753-01-01....>
no date - this fields is Nvarchar(10)
<BTW, what data will you actually have dating back to 1391? - who would have actually recorded data from back then?>
2013/07/07 = 1392/04/16 Shamsi (Persian) Date
-
text/sourcefragment 7/7/2013 7:09:31 PM Duane Dicks 0
I'm assuming that you have a separate date and time field.
It should work something like this:
create table #Mytest ( thedate nvarchar(10), theTime nvarchar(10) ) INSERT INTO #Mytest SELECT '1391\11\02', '08:59' UNION ALL SELECT '1391\11\02', '10:23' UNION ALL SELECT '1391\11\03', '08:00' UNION ALL SELECT '1391\11\03', '23:50' UNION ALL SELECT '1391\11\04', '07:59' UNION ALL SELECT '1391\11\04', '10:24' SELECT * FROM #Mytest WHERE theDate >= '1391/11/02' AND theTime > '10:21'
-
text/sourcefragment 7/7/2013 8:11:47 PM Duane Dicks 1
Sorry - you probably want this:
SELECT * FROM #Mytest WHERE (theDate = '1391\11\02' AND theTime > '10:21') OR thedate > '1391\11\02'
- Proposed as answer by Duane Dicks Sunday, July 07, 2013 8:12 PM
- Marked as answer by Allen Li - MSFTMicrosoft contingent staff, Moderator Wednesday, July 24, 2013 2:33 AM